Skip to content

Instantly share code, notes, and snippets.

@Hansimov
Last active June 29, 2021 08:39
Show Gist options
  • Save Hansimov/1783adcfb6f0e9c9fa220918b6cc88bd to your computer and use it in GitHub Desktop.
Save Hansimov/1783adcfb6f0e9c9fa220918b6cc88bd to your computer and use it in GitHub Desktop.

Install fastapi and uvicorn

pip install fastapi
pip install uvicorn

Run the service

Run following command:

  • default host and port is http://127.0.0.1:8000

uvicorn main:app --host <your_host_ip> --port <port> --reload

Go to http://<your_host_ip>:<port> to view the page.

from fastapi import FastAPI
app = FastAPI()
@app.get("/")
async def root():
return {"message": "Hello World"}
@app.get("/1")
async def sub():
return {"message": "sub 1"}
@app.get("/2")
async def sub():
return {"message": "sub 2"}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment