Spaces:
Running
Running
File size: 1,018 Bytes
9add385 f2a9b5f 305e0b4 9add385 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 |
from fastapi import FastAPI, APIRouter
app = FastAPI(title="General Purpose API", openapi_url="/openapi.json")
api_router = APIRouter()
from fastapi.middleware.cors import CORSMiddleware
# "http://localhost.tiangolo.com",
# "https://localhost.tiangolo.com",
# "http://localhost",
# "http://localhost:8080",
origins = [
"https://huggingface.co",
"https://huggingface.co/spaces/abhijitkumarjha88192/test-space",
"https://abhijitkumarjha88192-test-space.static.hf.space",
"http://localhost",
"http://localhost:8080",
"*"
]
app.add_middleware(
CORSMiddleware,
allow_origins=origins,
allow_credentials=True,
allow_methods=["*"],
allow_headers=["*"],
)
@api_router.get("/", status_code=200)
def root() -> dict:
"""
Root GET
"""
return {"msg": "Hello, World!"}
if __name__ == "__main__":
# Use this for debugging purposes only
app.include_router(api_router)
import uvicorn
uvicorn.run(app, host="0.0.0.0", port=8001, log_level="debug") |