Spaces:
Build error
Build error
| from fastapi import FastAPI | |
| from fastapi.staticfiles import StaticFiles | |
| from fastapi.responses import FileResponse | |
| import os | |
| app = FastAPI() | |
| # ربط ملفات الواجهة التي تم بناؤها في مجلد static_ui | |
| # ملاحظة: Dockerfile يقوم بنسخ ملفات Next.js إلى هذا المجلد | |
| if os.path.exists("static_ui"): | |
| app.mount("/", StaticFiles(directory="static_ui", html=True), name="static") | |
| def get_status(): | |
| return {"status": "Factory Online", "version": "2.0"} | |
| # في حال طلب المستخدم مسار غير موجود، نعود لصفحة الـ index (دعم الـ SPA) | |
| async def not_found_exception_handler(request, exc): | |
| return FileResponse("static_ui/index.html") | |
| if __name__ == "__main__": | |
| import uvicorn | |
| # بورت 7860 هو الافتراضي لـ Hugging Face Spaces | |
| uvicorn.run(app, host="0.0.0.0", port=7860) | |