A simple FastAPI application that collects data through a /append-data endpoint and stores it in a SQLite database.
- POST
/append-dataendpoint to submit data (name and value) - GET
/healthendpoint for health checks - Input validation using Pydantic
- SQLite database for storage with SQLAlchemy ORM
- Nginx configuration for reverse proxy
- Simple HTML/JavaScript frontend
- Basic logging and error handling
.
├── app
│ ├── __init__.py
│ ├── main.py
│ ├── database
│ │ ├── __init__.py
│ │ ├── database.py
│ │ ├── models.py
│ │ ├── schemas.py
│ │ └── data
│ │ └── app.db
│ └── static
│ └── index.html
├── nginx.conf
└── requirements.txt
python -m venv venv
venv\Scripts\activatepip install -r requirements.txtuvicorn app.main:app --host 0.0.0.0 --port 8000The application will be available at http://localhost:8000.
- Install Nginx if not already installed
- Copy the provided
nginx.confto your Nginx configuration directory - Restart Nginx to apply the changes
Open http://localhost:8000 in your browser to access the web interface.
curl -X POST "http://localhost:8000/append-data" \
-H "Content-Type: application/json" \
-d '{"name": "example", "value": 42.5}'fetch('http://localhost:8000/append-data', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
},
body: JSON.stringify({
name: 'example',
value: 42.5
}),
})
.then(response => response.json())
.then(data => console.log(data))
.catch(error => console.error('Error:', error));When the application is running, you can access the automatically generated API documentation at:
- Swagger UI: http://localhost:8000/docs
- ReDoc: http://localhost:8000/redoc
To terminate the currently running application, press Ctrl+C in the terminal where it's running.
To run the application again:
uvicorn app.main:app --host 0.0.0.0 --port 8000