File size: 726 Bytes
0b9dc2e
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
import os
import sys
from fastapi.responses import FileResponse

# Add the agent_service directory to sys.path
sys.path.append(os.path.join(os.path.dirname(__file__), "examples", "agent_service"))

from main import app as agentscope_app
import uvicorn

frontend_path = os.path.join(os.path.dirname(__file__), "examples", "web_ui", "frontend", "dist")

@agentscope_app.get("/{full_path:path}")
async def catch_all(full_path: str):
    file_path = os.path.join(frontend_path, full_path)
    if full_path and os.path.isfile(file_path):
        return FileResponse(file_path)
    return FileResponse(os.path.join(frontend_path, "index.html"))

if __name__ == "__main__":
    uvicorn.run(agentscope_app, host="0.0.0.0", port=7860)