Pant0x commited on
Commit
668cd87
·
1 Parent(s): cd01269

Update API URLs to point to Hugging Face Backend and support HF_TOKEN

Browse files
Files changed (3) hide show
  1. .gitignore +2 -0
  2. config.py +1 -1
  3. services/api_service.py +8 -1
.gitignore CHANGED
@@ -6,3 +6,5 @@ static/uploads/*
6
  venv/
7
  .vscode/
8
  .DS_Store
 
 
 
6
  venv/
7
  .vscode/
8
  .DS_Store
9
+
10
+ *.ps1
config.py CHANGED
@@ -6,7 +6,7 @@ load_dotenv(override=True)
6
 
7
  class Config:
8
  SECRET_KEY = os.getenv("FLASK_SECRET_KEY", "fallback-dev-key")
9
- BACKEND_API_URL = os.getenv("BACKEND_API_URL", "https://ain-el-aql-backend-production.up.railway.app")
10
  ESP_GATE_URL = os.getenv("ESP_GATE_URL", "http://192.168.1.100/open")
11
  PLATE_COOLDOWN_SECONDS = int(os.getenv("PLATE_COOLDOWN_SECONDS", "3"))
12
  CAMERA_SOURCE = os.getenv("CAMERA_SOURCE", "0")
 
6
 
7
  class Config:
8
  SECRET_KEY = os.getenv("FLASK_SECRET_KEY", "fallback-dev-key")
9
+ BACKEND_API_URL = os.getenv("BACKEND_API_URL", "https://pant0x-ain-el-aql-backend.hf.space")
10
  ESP_GATE_URL = os.getenv("ESP_GATE_URL", "http://192.168.1.100/open")
11
  PLATE_COOLDOWN_SECONDS = int(os.getenv("PLATE_COOLDOWN_SECONDS", "3"))
12
  CAMERA_SOURCE = os.getenv("CAMERA_SOURCE", "0")
services/api_service.py CHANGED
@@ -19,13 +19,20 @@ def _base_url() -> str:
19
  from flask import current_app
20
  return current_app.config["BACKEND_API_URL"].rstrip("/")
21
  except:
22
- return os.getenv("BACKEND_API_URL", "https://ain-el-aql-backend-production.up.railway.app").rstrip("/")
23
 
24
 
25
  def _headers(token: str | None = None) -> dict:
26
  h = {"Accept": "application/json"}
 
 
27
  if token:
 
28
  h["Authorization"] = f"Bearer {token}"
 
 
 
 
29
  return h
30
 
31
 
 
19
  from flask import current_app
20
  return current_app.config["BACKEND_API_URL"].rstrip("/")
21
  except:
22
+ return os.getenv("BACKEND_API_URL", "https://pant0x-ain-el-aql-backend.hf.space").rstrip("/")
23
 
24
 
25
  def _headers(token: str | None = None) -> dict:
26
  h = {"Accept": "application/json"}
27
+ hf_token = os.getenv("HF_TOKEN")
28
+
29
  if token:
30
+ # User session token
31
  h["Authorization"] = f"Bearer {token}"
32
+ elif hf_token:
33
+ # Fallback to HF space token for public endpoints (like OCR inference)
34
+ h["Authorization"] = f"Bearer {hf_token}"
35
+
36
  return h
37
 
38