from fastapi import FastAPI, Request, Response, status from fastapi.middleware.cors import CORSMiddleware from fastapi.responses import JSONResponse, FileResponse from fastapi.openapi.docs import get_swagger_ui_html import os app = FastAPI(docs_url=None, redoc_url=None, openapi_url=None) # Allow CORS from everywhere app.add_middleware( CORSMiddleware, allow_origins=["*"], allow_credentials=True, allow_methods=["*"], allow_headers=["*"], ) OPENAPI_YAML_PATH = os.path.join(os.path.dirname(__file__), "../openapi.yaml") @app.get("/", include_in_schema=False) def swagger_ui_html(): return get_swagger_ui_html( openapi_url="/openapi.yaml", title="Simple Social Media Application API" ) @app.get("/openapi.yaml", include_in_schema=False) def serve_openapi_yaml(): return FileResponse(OPENAPI_YAML_PATH, media_type="application/yaml") # ...endpoint implementations will be added here... if __name__ == "__main__": import uvicorn uvicorn.run("main:app", host="0.0.0.0", port=8000, reload=True)