clementBE commited on
Commit
2ce60e9
·
verified ·
1 Parent(s): 5a394aa

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +6 -1
app.py CHANGED
@@ -101,9 +101,14 @@ def fetch_image_endpoint(input_url: str):
101
  except Exception as e:
102
  raise HTTPException(status_code=500, detail=str(e))
103
 
 
 
 
 
 
104
  # This part serves the static files (like a frontend HTML page)
105
  # Note: You would need a 'static' folder with an 'index.html' file to see a UI.
106
- app.mount("/", StaticFiles(directory="static", html=True), name="static")
107
 
108
  # The root endpoint serves the main HTML page
109
  @app.get("/")
 
101
  except Exception as e:
102
  raise HTTPException(status_code=500, detail=str(e))
103
 
104
+ # Ensure the 'static' directory exists for mounting, preventing the RuntimeError
105
+ STATIC_DIR = "static"
106
+ if not os.path.exists(STATIC_DIR):
107
+ os.makedirs(STATIC_DIR)
108
+
109
  # This part serves the static files (like a frontend HTML page)
110
  # Note: You would need a 'static' folder with an 'index.html' file to see a UI.
111
+ app.mount("/", StaticFiles(directory=STATIC_DIR, html=True), name="static")
112
 
113
  # The root endpoint serves the main HTML page
114
  @app.get("/")