Spaces:
Sleeping
Sleeping
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", | |
"*" | |
] | |
app.add_middleware( | |
CORSMiddleware, | |
allow_origins=origins, | |
allow_credentials=True, | |
allow_methods=["*"], | |
allow_headers=["*"], | |
) | |
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") |