Created
September 30, 2020 00:44
-
-
Save shellkore/931b73de000fac8d26eb423c906b2997 to your computer and use it in GitHub Desktop.
fastAPI skeleton app
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
web: gunicorn -w 4 -k uvicorn.workers.UvicornWorker main:app |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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