Update app.py
Browse files
app.py
CHANGED
|
@@ -67,7 +67,7 @@ def process_image(image, project_name):
|
|
| 67 |
if not str(image).lower().endswith(('.jpg', '.jpeg', '.png')):
|
| 68 |
return "Error: Only JPG/PNG images are supported.", "Failure", "", "", 0
|
| 69 |
|
| 70 |
-
# Ensure the 'public_uploads' directory exists
|
| 71 |
upload_dir = "public_uploads"
|
| 72 |
os.makedirs(upload_dir, exist_ok=True)
|
| 73 |
|
|
@@ -123,7 +123,11 @@ def process_image(image, project_name):
|
|
| 123 |
app = FastAPI()
|
| 124 |
|
| 125 |
# Ensure the 'public_uploads' directory is created before serving
|
| 126 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 127 |
|
| 128 |
# Gradio UI
|
| 129 |
with gr.Blocks(css=".gradio-container {background-color: #f0f4f8; font-family: Arial;} .title {color: #2c3e50; font-size: 24px; text-align: center;}") as demo:
|
|
|
|
| 67 |
if not str(image).lower().endswith(('.jpg', '.jpeg', '.png')):
|
| 68 |
return "Error: Only JPG/PNG images are supported.", "Failure", "", "", 0
|
| 69 |
|
| 70 |
+
# Ensure the 'public_uploads' directory exists before attempting to save
|
| 71 |
upload_dir = "public_uploads"
|
| 72 |
os.makedirs(upload_dir, exist_ok=True)
|
| 73 |
|
|
|
|
| 123 |
app = FastAPI()
|
| 124 |
|
| 125 |
# Ensure the 'public_uploads' directory is created before serving
|
| 126 |
+
upload_dir = "public_uploads"
|
| 127 |
+
os.makedirs(upload_dir, exist_ok=True)
|
| 128 |
+
|
| 129 |
+
# Mount the 'public_uploads' directory to serve static files
|
| 130 |
+
app.mount("/file/public_uploads", StaticFiles(directory=upload_dir), name="public_uploads")
|
| 131 |
|
| 132 |
# Gradio UI
|
| 133 |
with gr.Blocks(css=".gradio-container {background-color: #f0f4f8; font-family: Arial;} .title {color: #2c3e50; font-size: 24px; text-align: center;}") as demo:
|