Update main.py
Browse files
main.py
CHANGED
|
@@ -129,6 +129,8 @@ def generate_prompts(prompt_text: str):
|
|
| 129 |
|
| 130 |
from fastapi import Query
|
| 131 |
|
|
|
|
|
|
|
| 132 |
@app.get("/send_inputs")
|
| 133 |
def send_inputs(
|
| 134 |
inputs: str,
|
|
@@ -147,12 +149,11 @@ def send_inputs(
|
|
| 147 |
return {"image_base64": image_base64}
|
| 148 |
else:
|
| 149 |
# Return an error message if the image couldn't be generated
|
| 150 |
-
|
| 151 |
except Exception as e:
|
| 152 |
# Log the error and return an error message
|
| 153 |
print(f"Error generating image: {e}")
|
| 154 |
-
|
| 155 |
-
|
| 156 |
|
| 157 |
|
| 158 |
app.mount("/", StaticFiles(directory="static", html=True), name="static")
|
|
|
|
| 129 |
|
| 130 |
from fastapi import Query
|
| 131 |
|
| 132 |
+
from fastapi import HTTPException
|
| 133 |
+
|
| 134 |
@app.get("/send_inputs")
|
| 135 |
def send_inputs(
|
| 136 |
inputs: str,
|
|
|
|
| 149 |
return {"image_base64": image_base64}
|
| 150 |
else:
|
| 151 |
# Return an error message if the image couldn't be generated
|
| 152 |
+
raise HTTPException(status_code=500, detail="Failed to generate image.")
|
| 153 |
except Exception as e:
|
| 154 |
# Log the error and return an error message
|
| 155 |
print(f"Error generating image: {e}")
|
| 156 |
+
raise HTTPException(status_code=500, detail="Failed to generate image.")
|
|
|
|
| 157 |
|
| 158 |
|
| 159 |
app.mount("/", StaticFiles(directory="static", html=True), name="static")
|