FastAPIとuvicornサーバーを使った簡易ロボットサーバー その1:環境構築
実際のところ
ライブラリのダウンロード
pip3 install fastapi uvicorn[standard]
最小動作確認
# ownserver.py from fastapi import FastAPI app = FastAPI() @app.get("/") async def root(): return {"message": "Hello World"} @app.get("/health") async def health_check(): return {"status": "ok"}
実行
$ uvicorn ownserver:app --reload --host 0.0.0.0 --port 8000
動作確認
$ curl http://localhost:8000/
{"message":"Hello World"}