Download app/server.py from austinbv/pdf_rag: direct link, hf CLI and curl.
- Browser
- Download file 793 Bytes
-
https://huggingface.co/spaces/austinbv/pdf_rag/resolve/main/app/server.py
- Command line
-
hf download hf://spaces/austinbv/pdf_rag/app/server.py
-
curl -L -o server.py https://huggingface.co/spaces/austinbv/pdf_rag/resolve/main/app/server.py
793 Bytes
| from fastapi import FastAPI | |
| from fastapi.responses import RedirectResponse | |
| from langserve import add_routes | |
| from fastapi.middleware.cors import CORSMiddleware | |
| from starlette.staticfiles import StaticFiles | |
| from app.rag_chain import final_chain | |
| app = FastAPI() | |
| app.add_middleware( | |
| CORSMiddleware, | |
| allow_origins=[ | |
| "http://localhost:3000" | |
| ], | |
| allow_credentials=True, | |
| allow_methods=["*"], | |
| allow_headers=["*"], | |
| ) | |
| app.mount("/rag/static", StaticFiles(directory="./source_docs"), name="static") | |
| async def redirect_root_to_docs(): | |
| return RedirectResponse("/docs") | |
| # Edit this to add the chain you want to add | |
| add_routes(app, final_chain, path="/rag") | |
| if __name__ == "__main__": | |
| import uvicorn | |
| uvicorn.run(app, host="0.0.0.0", port=8000) | |