Minimal FastAPI webserver example
This is the minimal FastAPI webserver
from fastapi import FastAPI
app = FastAPI()
@app.get("/")
async def read_root():
return {"message": "Hello, World!"}
if __name__ == "__main__":
import uvicorn
uvicorn.run(app, host="127.0.0.1", port=8000)
Run this script and then visit http://localhost:8000
in your browser to see:
{"message": "Hello, World!"}