yufii commited on
Commit
a875366
·
verified ·
1 Parent(s): c90cf25

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +7 -1
app.py CHANGED
@@ -28,7 +28,7 @@ app = FastAPI(port=8000)
28
 
29
  app.add_middleware(
30
  CORSMiddleware,
31
- allow_origins=["http://localhost:3000"],
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}")