Running FastAPI and Flask Web Services with Uvicorn/Gunicorn | NodeFlux.eu Docs

Deploy high-performance Python web applications and REST APIs using ASGI/WSGI production servers.

Steps

  1. For FastAPI: install fastapi and uvicorn in requirements.txt.
  2. For Flask: install flask and gunicorn in requirements.txt.
  3. Read PORT environment variable: port = int(os.environ.get("PORT", 8000)).
  4. For FastAPI, set uvicorn entry point: uvicorn.run("main:app", host="0.0.0.0", port=port).
  5. For Flask, set gunicorn start command: gunicorn -w 2 -b 0.0.0.0:$PORT main:app.
  6. Upload project files to your NodeFlux Python service.
  7. Start service and test web endpoints using your assigned host IP and port.

Notes