I am trying to run a "local" web app on Google Colab using FastAPI / Uvicorn like some of the Flask app sample code I've seen but cannot get it to work. Has anyone been able to do this? Appreciate it.
Installed FastAPI & Uvicorn successfully
!pip install FastAPI -q
!pip install uvicorn -q
Sample app
from fastapi import FastAPI
app = FastAPI()
@app.get("/")
async def root():
return {"message": "Hello World"}
Run attempts
#attempt 1
if __name__ == "__main__":
uvicorn.run("/content/fastapi_002:app", host="127.0.0.1", port=5000, log_level="info")
#attempt 2
#uvicorn main:app --reload
!uvicorn "/content/fastapi_001.ipynb:app" --reload