Minimaler FastAPI-Webserver-Beispiel
Dies ist der minimale FastAPI-Webserver
minimal_fastapi_app.py
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)Führen Sie dieses Skript aus und besuchen Sie dann http://localhost:8000 in Ihrem Browser, um zu sehen:
example_response.json
{"message": "Hello, World!"}If this post helped you, please consider buying me a coffee or donating via PayPal to support research & publishing of new posts on TechOverflow