FastAPI Example
This commit is contained in:
parent
3cf5b88d61
commit
6913ed2583
3 changed files with 27 additions and 0 deletions
1
.gitignore
vendored
Normal file
1
.gitignore
vendored
Normal file
|
@ -0,0 +1 @@
|
||||||
|
__pycache__
|
23
FastAPI Example/Example.py
Normal file
23
FastAPI Example/Example.py
Normal file
|
@ -0,0 +1,23 @@
|
||||||
|
from fastapi import FastAPI
|
||||||
|
from fastapi.responses import HTMLResponse
|
||||||
|
|
||||||
|
app = FastAPI()
|
||||||
|
|
||||||
|
|
||||||
|
# Simple Endpoint
|
||||||
|
@app.get("/")
|
||||||
|
def read_root():
|
||||||
|
return {"Hello": "World"}
|
||||||
|
|
||||||
|
# Simple GET Endpoint
|
||||||
|
@app.get("/items")
|
||||||
|
def read_item(item1, item2, item3):
|
||||||
|
return {"item1": item1,
|
||||||
|
"item2": item2,
|
||||||
|
"item3": item3}
|
||||||
|
|
||||||
|
# Simple Endpoint with HTML Response
|
||||||
|
@app.get("/html")
|
||||||
|
def read_html():
|
||||||
|
html = """<html><body>Welcome</body></html>"""
|
||||||
|
return HTMLResponse(content=html, status_code=200)
|
3
FastAPI Example/gunicorn.conf.py
Normal file
3
FastAPI Example/gunicorn.conf.py
Normal file
|
@ -0,0 +1,3 @@
|
||||||
|
bind = "127.0.0.1:8081"
|
||||||
|
workers = 1
|
||||||
|
worker_class = "uvicorn.workers.UvicornWorker"
|
Loading…
Reference in a new issue