Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -28,7 +28,7 @@ app = FastAPI(port=8000)
|
|
| 28 |
|
| 29 |
app.add_middleware(
|
| 30 |
CORSMiddleware,
|
| 31 |
-
allow_origins=["
|
| 32 |
allow_credentials=True,
|
| 33 |
allow_methods=["*"],
|
| 34 |
allow_headers=["*"],
|
|
@@ -38,6 +38,12 @@ app.add_middleware(
|
|
| 38 |
async def read_root():
|
| 39 |
return {"message": "Welcome to the Defects_model API"}
|
| 40 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 41 |
filepath = os.path.abspath("cnn_1_v6_final_model.h5")
|
| 42 |
if not os.path.exists(filepath):
|
| 43 |
raise FileNotFoundError(f"Model file not found at {filepath}")
|
|
|
|
| 28 |
|
| 29 |
app.add_middleware(
|
| 30 |
CORSMiddleware,
|
| 31 |
+
allow_origins=["*"],
|
| 32 |
allow_credentials=True,
|
| 33 |
allow_methods=["*"],
|
| 34 |
allow_headers=["*"],
|
|
|
|
| 38 |
async def read_root():
|
| 39 |
return {"message": "Welcome to the Defects_model API"}
|
| 40 |
|
| 41 |
+
@app.on_event("startup")
|
| 42 |
+
async def startup_event():
|
| 43 |
+
# Получаем URL приложения на Hugging Face Spaces
|
| 44 |
+
hugging_face_url = os.getenv("SPACE_URL", "URL не найден")
|
| 45 |
+
print(f"Приложение запущено и доступно по адресу: {hugging_face_url}")
|
| 46 |
+
|
| 47 |
filepath = os.path.abspath("cnn_1_v6_final_model.h5")
|
| 48 |
if not os.path.exists(filepath):
|
| 49 |
raise FileNotFoundError(f"Model file not found at {filepath}")
|