title: How to run FastAPI / Uvicorn in Google Colab?
body: <p>I am trying to run a &quot;local&quot; 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.</p>
  <h3>Installed FastAPI &amp; Uvicorn successfully</h3>
  <pre><code>!pip install FastAPI -q
  !pip install uvicorn -q
  </code></pre>
  <h3>Sample app</h3>
  <pre><code>from fastapi import FastAPI
  
  app = FastAPI()
  
  
  @app.get(&quot;/&quot;)
  async def root():
      return {&quot;message&quot;: &quot;Hello World&quot;}
  </code></pre>
  <h3>Run attempts</h3>
  <pre><code>#attempt 1
  if __name__ == &quot;__main__&quot;:
      uvicorn.run(&quot;/content/fastapi_002:app&quot;, host=&quot;127.0.0.1&quot;, port=5000, log_level=&quot;info&quot;)
  </code></pre>
  <h3></h3>
  <pre><code>#attempt 2
  #uvicorn main:app --reload
  !uvicorn &quot;/content/fastapi_001.ipynb:app&quot; --reload
  </code></pre>