fastapi.md 585 B

Fast API

pip3 install uvicorn[standard]
uvicorn main:app --host 0.0.0.0 --port 8080 --reload

CORS

from fastapi.responses import JSONResponse
from fastapi.middleware.cors import CORSMiddleware
db = dataset.connect('sqlite:///similar.db')


app = FastAPI()

origins = [
    "http://www.googo.org",
    "http://www.googo.org:8080",
    "http://googo.org:8080",
    "http://googo.org",
    "http://139.162.121.30"
]

app.add_middleware(
    CORSMiddleware,
    allow_origins=origins,
    allow_credentials=True,
    allow_methods=["*"],
    allow_headers=["*"],
)