Upload 13 files
Browse files
app.py
CHANGED
|
@@ -22,21 +22,6 @@ app.add_middleware(
|
|
| 22 |
allow_origins=["*"], allow_credentials=True, allow_methods=["*"], allow_headers=["*"],
|
| 23 |
)
|
| 24 |
|
| 25 |
-
# Mount frontend directory
|
| 26 |
-
frontend_path = os.path.join(os.path.dirname(__file__), "frontend")
|
| 27 |
-
if os.path.exists(frontend_path):
|
| 28 |
-
print(f"Montando frontend estático em: {frontend_path}")
|
| 29 |
-
app.mount("/static", StaticFiles(directory=frontend_path), name="static")
|
| 30 |
-
|
| 31 |
-
@app.get("/")
|
| 32 |
-
async def read_index():
|
| 33 |
-
return FileResponse(os.path.join(frontend_path, "index.html"))
|
| 34 |
-
else:
|
| 35 |
-
print(f"⚠️ Frontend não encontrado em: {frontend_path}")
|
| 36 |
-
@app.get("/")
|
| 37 |
-
def root():
|
| 38 |
-
return {"message": "Servidor J.A.D.E. com FastAPI está online. Frontend não encontrado."}
|
| 39 |
-
|
| 40 |
# Dicionário global para armazenar sessões de usuários
|
| 41 |
user_sessions = {}
|
| 42 |
scholar_sessions = {} # Armazena instâncias de ScholarAgent por usuário
|
|
@@ -200,6 +185,19 @@ def handle_scholar(request: ScholarRequest):
|
|
| 200 |
print(f"Erro no Scholar Agent: {e}")
|
| 201 |
return {"success": False, "error": str(e)}
|
| 202 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 203 |
if __name__ == "__main__":
|
| 204 |
import uvicorn
|
| 205 |
port = int(os.environ.get("PORT", 7860))
|
|
|
|
| 22 |
allow_origins=["*"], allow_credentials=True, allow_methods=["*"], allow_headers=["*"],
|
| 23 |
)
|
| 24 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 25 |
# Dicionário global para armazenar sessões de usuários
|
| 26 |
user_sessions = {}
|
| 27 |
scholar_sessions = {} # Armazena instâncias de ScholarAgent por usuário
|
|
|
|
| 185 |
print(f"Erro no Scholar Agent: {e}")
|
| 186 |
return {"success": False, "error": str(e)}
|
| 187 |
|
| 188 |
+
# Mount frontend directory
|
| 189 |
+
# IMPORTANT: This must be the last route/mount to avoid shadowing API endpoints
|
| 190 |
+
frontend_path = os.path.join(os.path.dirname(__file__), "frontend")
|
| 191 |
+
if os.path.exists(frontend_path):
|
| 192 |
+
print(f"Montando frontend estático em: {frontend_path}")
|
| 193 |
+
# Mount at root "/" to serve index.html and assets directly
|
| 194 |
+
app.mount("/", StaticFiles(directory=frontend_path, html=True), name="frontend")
|
| 195 |
+
else:
|
| 196 |
+
print(f"⚠️ Frontend não encontrado em: {frontend_path}")
|
| 197 |
+
@app.get("/")
|
| 198 |
+
def root():
|
| 199 |
+
return {"message": "Servidor J.A.D.E. com FastAPI está online. Frontend não encontrado."}
|
| 200 |
+
|
| 201 |
if __name__ == "__main__":
|
| 202 |
import uvicorn
|
| 203 |
port = int(os.environ.get("PORT", 7860))
|