A simple Python Flask API for uploading files via curl or other HTTP clients.
- Simple API endpoint for file uploads
- Stores files locally in
uploads/directory - JSON responses
- Secure filename handling
- 100MB max file size
- Uses uv inline dependencies (no separate requirements.txt needed)
chmod +x app.py
./app.pyThe server will start on http://localhost:5000
# Upload a file
curl -F 'file=@/path/to/your/file.txt' http://localhost:5000/upload
# Upload with verbose output
curl -v -F 'file=@document.pdf' http://localhost:5000/upload
# Upload and save response to a file
curl -F 'file=@image.png' http://localhost:5000/upload -o response.jsonSuccess (201):
{
"message": "File uploaded successfully",
"filename": "file.txt",
"path": "uploads/file.txt",
"size": 1024
}Error (400):
{
"error": "No file part in the request"
}curl http://localhost:5000/healthEdit these variables in app.py:
UPLOAD_FOLDER: Directory where files are stored (default: 'uploads')MAX_CONTENT_LENGTH: Maximum file size in bytes (default: 100MB)
- Python 3.10+
- uv (https://docs.astral.sh/uv/)