randydev commited on
Commit
642975c
1 Parent(s): 911e2e6

Upload main.py

Browse files
Files changed (1) hide show
  1. main.py +7 -9
main.py CHANGED
@@ -804,7 +804,8 @@ def get_llama(query: str):
804
  @app.get("/ryuzaki/waifu")
805
  def waifu_pics(
806
  types: str="sfw",
807
- category: str="neko"
 
808
  ):
809
  waifu_api = f"{SOURCE_WAIFU_URL}/{types}"
810
  waifu_param = f"{waifu_api}/{category}"
@@ -820,14 +821,11 @@ def waifu_pics(
820
  return f"Error request {e}"
821
  if waifu_image_url:
822
  try:
823
- return {
824
- "status": "true",
825
- "randydev":{
826
- "image_url": waifu_image_url
827
- }
828
- }
829
- except:
830
- return {"status": "false", "message": "Error response"}
831
  else:
832
  return {"status": "false", "message": "Error response."}
833
 
 
804
  @app.get("/ryuzaki/waifu")
805
  def waifu_pics(
806
  types: str="sfw",
807
+ category: str="neko",
808
+ media_type: str=None
809
  ):
810
  waifu_api = f"{SOURCE_WAIFU_URL}/{types}"
811
  waifu_param = f"{waifu_api}/{category}"
 
821
  return f"Error request {e}"
822
  if waifu_image_url:
823
  try:
824
+ response_two = requests.get(waifu_image_url)
825
+ response_two.raise_for_status()
826
+ except requests.exceptions.RequestException:
827
+ raise HTTPException(status_code=500, detail="Internal server error")
828
+ return StreamingResponse(BytesIO(response_two.content), media_type=media_type)
 
 
 
829
  else:
830
  return {"status": "false", "message": "Error response."}
831