Spaces:
Paused
Paused
pseudotheos
commited on
Commit
•
a6c8ce4
1
Parent(s):
6f02348
Update app.py
Browse files
app.py
CHANGED
@@ -214,6 +214,14 @@ def generate_image_from_parameters(prompt, guidance_scale, controlnet_scale, con
|
|
214 |
# Handle exceptions and return an error message if something goes wrong
|
215 |
return str(e)
|
216 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
217 |
@app.post("/generate_image")
|
218 |
async def generate_image(
|
219 |
prompt: str = Form(...),
|
@@ -248,8 +256,8 @@ async def generate_image(
|
|
248 |
return StreamingResponse(content=output_image_io, media_type="image/png")
|
249 |
|
250 |
except Exception as e:
|
251 |
-
|
252 |
-
return
|
253 |
|
254 |
if __name__ == "__main__":
|
255 |
import uvicorn
|
|
|
214 |
# Handle exceptions and return an error message if something goes wrong
|
215 |
return str(e)
|
216 |
|
217 |
+
app.add_middleware(
|
218 |
+
CORSMiddleware,
|
219 |
+
allow_origins=["*"], # You can replace ["*"] with specific origins if needed
|
220 |
+
allow_credentials=True,
|
221 |
+
allow_methods=["*"], # Allow all methods
|
222 |
+
allow_headers=["*"], # Allow all headers
|
223 |
+
)
|
224 |
+
|
225 |
@app.post("/generate_image")
|
226 |
async def generate_image(
|
227 |
prompt: str = Form(...),
|
|
|
256 |
return StreamingResponse(content=output_image_io, media_type="image/png")
|
257 |
|
258 |
except Exception as e:
|
259 |
+
logger.error("Error occurred during image generation: %s", str(e))
|
260 |
+
return "Failed to generate image"
|
261 |
|
262 |
if __name__ == "__main__":
|
263 |
import uvicorn
|