Simple file management API built with Flask and PostgreSQL.
2.4K
Simple file management API built with Flask and PostgreSQL.
The backend handles file operations like creating folders, uploading files, and managing permissions. It runs as separate services for better performance.
The backend splits into 4 services:
All services share the same database. Nginx routes requests by HTTP method.
apps/backend/
├── app_factory.py # Creates Flask apps
├── routes_read.py # GET endpoints
├── routes_write.py # POST endpoints
├── routes_operations.py # PUT/DELETE endpoints
├── models.py # Database tables
├── run_bjoern.py # Production server
├── start_local.py # Development server
└── tests/ # Unit tests
Uses SQLAlchemy with these tables:
Key features:
File operations:
GET /api/filesystem - List files in folderPOST /api/filesystem - Create new folderGET /api/filesystem/{id} - Get file detailsPUT /api/filesystem/{id} - Rename file/folderDELETE /api/filesystem/{id} - Delete file/folderPOST /api/filesystem/upload - Upload fileGET /api/filesystem/{id}/download - Download fileSystem:
GET /api/health - Check if service is runningUses Auth0 JWT tokens. Set TEST_MODE=true to skip auth during development.
Create apps/backend/.env:
DATABASE_URL=postgresql://user:pass@localhost:5432/flask_react_db
SECRET_KEY=your-secret-key
AUTH0_DOMAIN=your-tenant.auth0.com
AUTH0_AUDIENCE=your-api-identifier
TEST_MODE=false
Start local server:
cd apps/backend
python start_local.py
Run tests:
cd apps/backend
pytest tests/ -v
Database migrations:
cd apps/backend
flask db upgrade
Uses bjoern WSGI server for performance. Docker containers run each service separately. Nginx handles load balancing and routing.
Database connection fails:
Auth errors:
Port conflicts:
Content type
Image
Digest
sha256:1b0f585af…
Size
159.9 MB
Last updated
3 months ago
docker pull h4mid2019/flask-react-backend