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

Upload main.py

Browse files
Files changed (1) hide show
  1. main.py +16 -7
main.py CHANGED
@@ -805,7 +805,8 @@ def get_llama(query: str):
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}"
@@ -820,12 +821,20 @@ def waifu_pics(
820
  except Exception as e:
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
 
 
805
  def waifu_pics(
806
  types: str="sfw",
807
  category: str="neko",
808
+ media_type: str=None,
809
+ is_bytes: bool=False
810
  ):
811
  waifu_api = f"{SOURCE_WAIFU_URL}/{types}"
812
  waifu_param = f"{waifu_api}/{category}"
 
821
  except Exception as e:
822
  return f"Error request {e}"
823
  if waifu_image_url:
824
+ if is_bytes:
825
+ try:
826
+ response_two = requests.get(waifu_image_url)
827
+ response_two.raise_for_status()
828
+ except requests.exceptions.RequestException:
829
+ raise HTTPException(status_code=500, detail="Internal server error")
830
+ return StreamingResponse(BytesIO(response_two.content), media_type=media_type)
831
+ else:
832
+ return {
833
+ "status": "true",
834
+ "randydev":{
835
+ "image_url": waifu_image_url
836
+ }
837
+ }
838
  else:
839
  return {"status": "false", "message": "Error response."}
840