Spaces:
Running
Running
Update main.py
Browse files
main.py
CHANGED
@@ -549,6 +549,27 @@ async def usage_page():
|
|
549 |
</html>
|
550 |
"""
|
551 |
return HTMLResponse(content=html_content)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
552 |
@app.on_event("startup")
|
553 |
async def startup_event():
|
554 |
global available_model_ids
|
|
|
549 |
</html>
|
550 |
"""
|
551 |
return HTMLResponse(content=html_content)
|
552 |
+
@app.get("/meme")
|
553 |
+
async def get_meme():
|
554 |
+
try:
|
555 |
+
response = requests.get("https://meme-api.com/gimme")
|
556 |
+
response_data = response.json()
|
557 |
+
|
558 |
+
meme_url = response_data.get("url")
|
559 |
+
|
560 |
+
if meme_url:
|
561 |
+
def stream_image():
|
562 |
+
with requests.get(meme_url, stream=True) as image_response:
|
563 |
+
for chunk in image_response.iter_content(chunk_size=1024):
|
564 |
+
yield chunk
|
565 |
+
|
566 |
+
return StreamingResponse(stream_image(), media_type="image/png")
|
567 |
+
else:
|
568 |
+
raise HTTPException(status_code=404, detail="No mimi found :(")
|
569 |
+
|
570 |
+
except Exception as e:
|
571 |
+
raise HTTPException(status_code=500, detail=str(e))
|
572 |
+
|
573 |
@app.on_event("startup")
|
574 |
async def startup_event():
|
575 |
global available_model_ids
|