Refactor: fix async errors, CRLF line endings and bot tokens.

This commit is contained in:
2026-03-24 00:02:56 +00:00
parent b7e6239216
commit cb729809a9
6 changed files with 103 additions and 105 deletions

11
main.py
View File

@@ -5,14 +5,14 @@ import time
import json
import asyncio
from fastapi import FastAPI, Request, Header, Depends, HTTPException, status
from fastapi.responses import HTMLResponse, JSONResponse
from fastapi.responses import HTMLResponse, JSONResponse, FileResponse
from fastapi.templating import Jinja2Templates
from dotenv import load_dotenv
from starlette.concurrency import run_in_threadpool
from ai_agent import query_agent
from config import get_config, save_config
from credential_manager import sync_credentials, sync_from_gitea_repo
from credential_manager import fetch_from_gitea_repo_async
from orchestrator import (
orchestrate_async, handle_message_async, get_orchestrator_status,
get_llm_config, set_llm_config, format_confirmation_message,
@@ -30,8 +30,7 @@ templates = Jinja2Templates(directory="templates")
@app.on_event("startup")
async def startup_event():
print("[INIT] Sincronizando credenciais...")
sync_from_gitea_repo()
sync_credentials()
await fetch_from_gitea_repo_async(force=True)
# --- SEGURANÇA ---
async def verify_password(x_web_password: str = Header(None)):
@@ -41,9 +40,9 @@ async def verify_password(x_web_password: str = Header(None)):
return True
# --- WEB UI ---
@app.get("/", response_class=HTMLResponse)
@app.get("/", response_class=FileResponse)
async def read_root(request: Request):
return templates.TemplateResponse("index.html", {"request": request})
return FileResponse("templates/index.html")
@app.get("/api/status")
async def get_system_status(is_auth: bool = Depends(verify_password)):