forked from opea-project/GenAIStudio
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.py
More file actions
42 lines (33 loc) · 1.36 KB
/
main.py
File metadata and controls
42 lines (33 loc) · 1.36 KB
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
from fastapi import FastAPI
from fastapi.middleware.cors import CORSMiddleware
from app.compat import ensure_urllib3_getheaders
# Restore HTTPResponse.getheaders expected by kubernetes-python when running with urllib3 2.x.
ensure_urllib3_getheaders()
from kubernetes import config
# Load the kubeconfig file
try:
# Try to load in-cluster configuration
config.load_incluster_config()
print("Loaded in-cluster configuration")
except config.ConfigException:
# If in-cluster configuration fails, fall back to kube-config file
config.load_kube_config()
print("Loaded kube-config file")
app = FastAPI()
@app.get("/studio-backend/health")
def read_health():
return {"status": "ok"}
app.add_middleware(
CORSMiddleware,
allow_origins=["*"],
allow_credentials=True,
allow_methods=["*"],
allow_headers=["*"],
)
from .routers import user_router, download_router, sandbox_router, llmtraces_router, debuglog_router, clickdeploy_router
app.include_router(user_router.router, prefix="/studio-backend")
app.include_router(download_router.router, prefix="/studio-backend")
app.include_router(sandbox_router.router, prefix="/studio-backend")
app.include_router(llmtraces_router.router, prefix="/studio-backend")
app.include_router(debuglog_router.router, prefix="/studio-backend")
app.include_router(clickdeploy_router.router, prefix="/studio-backend")