Created
April 30, 2021 23:45
-
-
Save avilior/fc3bcfa3bc916216edec1ef5dfecddd0 to your computer and use it in GitHub Desktop.
FastApi
This file contains hidden or 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
#!/usr/bin/env python3 | |
# -*- coding: utf-8 -*- | |
from fastapi import FastAPI | |
import logging | |
LOG = logging.getLogger(__name__) | |
app = FastAPI() | |
@app.on_event("startup") | |
async def on_start_up(): | |
LOG.info("Start Up procedures...") | |
LOG.info("Start up procedures DONE") | |
@app.on_event("shutdown") | |
async def on_shutdown(): | |
LOG.info("Shutdown procedures...") | |
LOG.info("Shutdown procedures DONE") | |
@app.get('/') | |
async def hello(): | |
return F"Hello From Fast API: {__name__}" | |
if __name__ == '__main__': | |
import uvloop | |
import uvicorn | |
logging.basicConfig( | |
filename=None, | |
filemode="a", | |
format='%(asctime)-15s|%(levelname)-8s|%(filename)-25s|%(funcName)-15s|%(lineno)-4s|%(message)s', | |
level=logging.INFO | |
) | |
uvloop.install() | |
uvicorn.run(app, host="0.0.0.0", port=9000, log_level="info") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment