rongo1 commited on
Commit
1e9afab
·
1 Parent(s): 50ef2fd

feat: set a password

Browse files
Files changed (3) hide show
  1. app.py +12 -1
  2. env.example +6 -0
  3. setup_hf_space.md +9 -1
app.py CHANGED
@@ -761,4 +761,15 @@ with gr.Blocks(title="Business Card Data Extractor") as demo:
761
 
762
  # Launch for Hugging Face Spaces deployment
763
  logger.info("Starting Gradio demo")
764
- demo.launch()
 
 
 
 
 
 
 
 
 
 
 
 
761
 
762
  # Launch for Hugging Face Spaces deployment
763
  logger.info("Starting Gradio demo")
764
+
765
+ # Get password from environment variable for authentication
766
+ hf_space_password = os.getenv("SPACE_PASSWORD")
767
+
768
+ if hf_space_password:
769
+ # Launch with password protection
770
+ logger.info("Launching with password protection enabled")
771
+ demo.launch(auth=("user", hf_space_password))
772
+ else:
773
+ # Launch without password protection
774
+ logger.warning("SPACE_PASSWORD not set - launching without password protection")
775
+ demo.launch()
env.example CHANGED
@@ -21,6 +21,12 @@ GOOGLE_CLIENT_SECRET=your_google_client_secret_here
21
  # For deployment: Set this to the base64 encoded token string
22
  GOOGLE_TOKEN_BASE64=your_base64_encoded_token_here
23
 
 
 
 
 
 
 
24
  # Examples:
25
  # Gemini_API=AIzaSyBxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
26
  # GOOGLE_CLIENT_ID=1234567890-abcdefghijklmnopqrstuvwxyz.apps.googleusercontent.com
 
21
  # For deployment: Set this to the base64 encoded token string
22
  GOOGLE_TOKEN_BASE64=your_base64_encoded_token_here
23
 
24
+ # Hugging Face Space Password (Optional - for password protection)
25
+ # Set this to enable password protection when making your Space public
26
+ # Users will need to login with username: "user" and this password
27
+ # For deployment: Add this as a secret in your Space settings
28
+ HF_SPACE_PASSWORD=your_space_password_here
29
+
30
  # Examples:
31
  # Gemini_API=AIzaSyBxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
32
  # GOOGLE_CLIENT_ID=1234567890-abcdefghijklmnopqrstuvwxyz.apps.googleusercontent.com
setup_hf_space.md CHANGED
@@ -28,9 +28,16 @@ business_cards/.gitkeep
28
  1. Go to your Space **Settings**
29
  2. Scroll to **Repository secrets**
30
  3. Click **Add a new secret**
31
- 4. Set:
 
 
32
  - **Name**: `Gemini_API`
33
  - **Value**: Your AI API key
 
 
 
 
 
34
 
35
  ### 4. Get Your AI API Key
36
  1. Go to [Google AI Studio](https://aistudio.google.com/)
@@ -52,6 +59,7 @@ business_cards/.gitkeep
52
 
53
  ## Environment Variables Required
54
  - `Gemini_API`: Your AI API key (required)
 
55
 
56
  ## Notes
57
  - The space will create necessary directories automatically
 
28
  1. Go to your Space **Settings**
29
  2. Scroll to **Repository secrets**
30
  3. Click **Add a new secret**
31
+ 4. Add these secrets:
32
+
33
+ **Required:**
34
  - **Name**: `Gemini_API`
35
  - **Value**: Your AI API key
36
+
37
+ **Optional (for password protection):**
38
+ - **Name**: `HF_SPACE_PASSWORD`
39
+ - **Value**: Your desired password
40
+ - **Note**: Users will login with username: `user` and this password
41
 
42
  ### 4. Get Your AI API Key
43
  1. Go to [Google AI Studio](https://aistudio.google.com/)
 
59
 
60
  ## Environment Variables Required
61
  - `Gemini_API`: Your AI API key (required)
62
+ - `HF_SPACE_PASSWORD`: Password for space access (optional)
63
 
64
  ## Notes
65
  - The space will create necessary directories automatically