hackerbyhobby commited on
Commit
047a196
·
unverified ·
1 Parent(s): bcbc2f7

more updates

Browse files
Files changed (1) hide show
  1. app.py +6 -8
app.py CHANGED
@@ -8,6 +8,7 @@ from deep_translator import GoogleTranslator
8
  import shap
9
  import requests
10
  import json
 
11
 
12
  # Translator instance
13
  translator = GoogleTranslator(source="auto", target="es")
@@ -27,15 +28,12 @@ CANDIDATE_LABELS = ["SMiShing", "Other Scam", "Legitimate"]
27
  # SHAP explainer setup
28
  explainer = shap.Explainer(classifier)
29
 
30
- # Prompt the user for their Google Safe Browsing API key
31
- def get_api_key():
32
- """Prompt the user for their API key."""
33
- api_key = input("Please enter your Google Safe Browsing API key: ").strip()
34
- if not api_key:
35
- raise ValueError("API key is required to use the application.")
36
- return api_key
37
 
38
- SAFE_BROWSING_API_KEY = get_api_key()
39
  SAFE_BROWSING_URL = "https://safebrowsing.googleapis.com/v4/threatMatches:find"
40
 
41
  def check_url_with_google_safebrowsing(url):
 
8
  import shap
9
  import requests
10
  import json
11
+ import os
12
 
13
  # Translator instance
14
  translator = GoogleTranslator(source="auto", target="es")
 
28
  # SHAP explainer setup
29
  explainer = shap.Explainer(classifier)
30
 
31
+ # Retrieve the Google Safe Browsing API key from the environment
32
+ SAFE_BROWSING_API_KEY = os.getenv("SAFE_BROWSING_API_KEY")
33
+
34
+ if not SAFE_BROWSING_API_KEY:
35
+ raise ValueError("Google Safe Browsing API key not found. Please set it as an environment variable in your Hugging Face Space.")
 
 
36
 
 
37
  SAFE_BROWSING_URL = "https://safebrowsing.googleapis.com/v4/threatMatches:find"
38
 
39
  def check_url_with_google_safebrowsing(url):