Spaces:
Sleeping
Sleeping
Update app.py
Browse files
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=
|
| 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("/")
|