LT360 commited on
Commit
30cda43
·
1 Parent(s): eccd941

Update CORS

Browse files
Files changed (2) hide show
  1. app/main.py +3 -4
  2. app/ml_logic.py +0 -1
app/main.py CHANGED
@@ -9,9 +9,9 @@ from .ml import get_model_prediction, check_model_status
9
 
10
  app = FastAPI(title="AI-Powered Phishing Email Detection System")
11
 
12
- # Determine your specific Hugging Face Space direct URL
13
- # Example: "https://username-spacename.hf.space"
14
  HF_SPACE_DIRECT_URL = "https://lleratodev-multinomial-nb-phishing-email-detection-api.hf.space"
 
15
  HF_SPACE_OLD_URL = "https://huggingface.co/spaces/lleratodev/multinomial-nb-phishing-email-detection-api"
16
 
17
  # Define allowed origins for CORS
@@ -19,6 +19,7 @@ origins = [
19
  "https://ai-powered-phishing-email-detection-system.vercel.app", # Our Next.js frontend hosted on Vercel
20
  "http://localhost:3000", # Local development
21
  HF_SPACE_DIRECT_URL, # Specific direct URL for Hugging Face Space
 
22
  HF_SPACE_OLD_URL, # Older Hugging Face Space URL
23
  # Regex to match any other *.hf.space subdomains if needed.
24
  # This matches https://<any-subdomain(s)>.hf.space
@@ -59,12 +60,10 @@ async def get_debug_info():
59
  cwd = os.getcwd()
60
  ls_output = subprocess.check_output(["ls", "-la", cwd], text=True)
61
  env_vars = dict(os.environ)
62
- # Add more commands or info as needed
63
  return {
64
  "cwd": cwd,
65
  "ls_output": ls_output,
66
  "environment_variables": env_vars
67
- # Be careful not to expose sensitive environment variables
68
  }
69
  except Exception as e:
70
  return {"error": str(e)}
 
9
 
10
  app = FastAPI(title="AI-Powered Phishing Email Detection System")
11
 
12
+ # Hugging face URLs
 
13
  HF_SPACE_DIRECT_URL = "https://lleratodev-multinomial-nb-phishing-email-detection-api.hf.space"
14
+ HF_SPACE_MAIN = "https://huggingface.co/spaces/lleratodev/multinomial-nb-phishing-email-detection-api"
15
  HF_SPACE_OLD_URL = "https://huggingface.co/spaces/lleratodev/multinomial-nb-phishing-email-detection-api"
16
 
17
  # Define allowed origins for CORS
 
19
  "https://ai-powered-phishing-email-detection-system.vercel.app", # Our Next.js frontend hosted on Vercel
20
  "http://localhost:3000", # Local development
21
  HF_SPACE_DIRECT_URL, # Specific direct URL for Hugging Face Space
22
+ HF_SPACE_MAIN, # API URL
23
  HF_SPACE_OLD_URL, # Older Hugging Face Space URL
24
  # Regex to match any other *.hf.space subdomains if needed.
25
  # This matches https://<any-subdomain(s)>.hf.space
 
60
  cwd = os.getcwd()
61
  ls_output = subprocess.check_output(["ls", "-la", cwd], text=True)
62
  env_vars = dict(os.environ)
 
63
  return {
64
  "cwd": cwd,
65
  "ls_output": ls_output,
66
  "environment_variables": env_vars
 
67
  }
68
  except Exception as e:
69
  return {"error": str(e)}
app/ml_logic.py CHANGED
@@ -31,7 +31,6 @@ except Exception as e:
31
  model = None
32
 
33
  # --- Load BERT-mini model and tokenizer from Hugging Face Hub ---
34
- # Replace with your actual Hugging Face model ID
35
  BERT_MODEL_ID = "lleratodev/720-bert-mini-phishing" # e.g., "LeratoLetsepe/phishing-bert-mini"
36
  try:
37
  bert_tokenizer = AutoTokenizer.from_pretrained(BERT_MODEL_ID)
 
31
  model = None
32
 
33
  # --- Load BERT-mini model and tokenizer from Hugging Face Hub ---
 
34
  BERT_MODEL_ID = "lleratodev/720-bert-mini-phishing" # e.g., "LeratoLetsepe/phishing-bert-mini"
35
  try:
36
  bert_tokenizer = AutoTokenizer.from_pretrained(BERT_MODEL_ID)