Skip to content

Instantly share code, notes, and snippets.

@shellkore
Created September 30, 2020 00:44
Show Gist options
  • Save shellkore/931b73de000fac8d26eb423c906b2997 to your computer and use it in GitHub Desktop.
Save shellkore/931b73de000fac8d26eb423c906b2997 to your computer and use it in GitHub Desktop.
fastAPI skeleton app
from fastapi import FastAPI
from pydantic import BaseModel
from typing import Optional
import uvicorn
app = FastAPI()
# class Sample(BaseModel):
# id: int
# name: str
@app.get('/')
def index():
return {'msg':'API working. Check /docs for more'}
# Optional usage
@app.get('/items/{item_id}')
async def get_item(item_id: int, q: Optional[str] = None):
return {'item_id':item_id,'q':q}
if __name__ == '__main__':
uvicorn.run(app)
web: gunicorn -w 4 -k uvicorn.workers.UvicornWorker main:app
pydantic==1.6.1
fastapi==0.61.1
uvicorn==0.12.0
gunicorn
uvloop
httptools
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment