File size: 1,310 Bytes
57cab59
 
 
819bacd
 
 
fe7c659
819bacd
fe7c659
57cab59
 
 
 
 
 
 
819bacd
 
 
57cab59
 
819bacd
57cab59
 
 
 
 
 
 
 
 
 
819bacd
 
57cab59
 
 
 
 
819bacd
 
 
 
 
 
 
 
 
 
 
 
 
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
49
50
51
52
53
import uvicorn
from fastapi import APIRouter, FastAPI
from fastapi.middleware.cors import CORSMiddleware
from fastapi.responses import FileResponse
from fastapi.staticfiles import StaticFiles

from app.modules.querySearch.routes.querySearch_route import \
    router as query_search_routes
from app.modules.uploadDocument.routes.uploadDocument_route import \
    router as upload_file_routes

app = FastAPI()

origins = [
    "http://localhost:8000",
    "http://localhost:3000",
    "https://your-space-name.hf.space",
    "localhost:8000",
    "https://abadesalex-docurag.hf.space/api",
]


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

app_router = APIRouter(prefix="/api")
app_router.include_router(upload_file_routes, prefix="/upload", tags=["upload"])
app_router.include_router(query_search_routes, prefix="/query", tags=["query"])


@app_router.get("/")
async def root():
    return {"message": "Hello World"}


# Serve static files from the 'out/_next/static' directory
app.mount("/_next/static", StaticFiles(directory="src/out/_next/static"), name="static")

# Serve the main index.html
@app.get("/")
def read_root():
    return FileResponse("src/out/index.html")




app.include_router(app_router)