dcorcoran commited on
Commit
ea28818
·
1 Parent(s): ebfd963

Changed backend url

Browse files
Files changed (2) hide show
  1. api_client.py +2 -3
  2. app.py +7 -3
api_client.py CHANGED
@@ -2,13 +2,12 @@ import requests
2
  import os
3
 
4
  #BACKEND_URL = "http://localhost:8000"
5
- BACKEND_URL = os.getenv("BACKEND_URL", "https://huggingface.co/spaces/dcorcoran/Pokemon_Card_Image_Processor_API")
6
-
7
 
8
  def predict(image_bytes: bytes, filename: str) -> dict:
9
  try:
10
  response = requests.post(
11
- f"{BACKEND_URL}/predict",
12
  files={"file": (filename, image_bytes, "image/png")}
13
  )
14
  response.raise_for_status()
 
2
  import os
3
 
4
  #BACKEND_URL = "http://localhost:8000"
5
+ BACKEND_URL = os.getenv("BACKEND_URL", "https://dcorcoran-Pokemon_Card_Image_Processor_API.hf.space")
 
6
 
7
  def predict(image_bytes: bytes, filename: str) -> dict:
8
  try:
9
  response = requests.post(
10
+ f"{BACKEND_URL}/api/predict",
11
  files={"file": (filename, image_bytes, "image/png")}
12
  )
13
  response.raise_for_status()
app.py CHANGED
@@ -1,6 +1,7 @@
1
  import streamlit as st
2
  from PIL import Image
3
  import io
 
4
 
5
  from api_client import predict, health_check
6
  from components.upload_section import render_upload_section
@@ -32,9 +33,12 @@ st.caption("Upload a Pokémon card image to extract its data and find similar ca
32
  # ----- BACKEND STATUS -----------
33
  # --------------------------------
34
 
35
- if not health_check():
36
- st.error("⚠️ Backend is not running. Start it with: uvicorn app.main:app --reload")
37
- st.stop()
 
 
 
38
 
39
 
40
 
 
1
  import streamlit as st
2
  from PIL import Image
3
  import io
4
+ import requests
5
 
6
  from api_client import predict, health_check
7
  from components.upload_section import render_upload_section
 
33
  # ----- BACKEND STATUS -----------
34
  # --------------------------------
35
 
36
+ def health_check():
37
+ try:
38
+ response = requests.get(f"{BASE_URL}/health")
39
+ return response.status_code == 200
40
+ except:
41
+ return False
42
 
43
 
44