kaeizen commited on
Commit
0f55242
·
1 Parent(s): 1a959bc

Update Dockerfile, env example and settings

Browse files
Files changed (4) hide show
  1. .env.example +24 -127
  2. Dockerfile +17 -14
  3. README.md +30 -25
  4. backend/settings.py +18 -12
.env.example CHANGED
@@ -1,136 +1,33 @@
1
- # =============================================================================
2
- # Django Backend Environment Variables
3
- # =============================================================================
4
- # Copy this file to .env and fill in your actual values
5
- # Never commit .env to version control (it should be in .gitignore)
6
- # =============================================================================
7
 
8
- # -----------------------------------------------------------------------------
9
- # Required Settings
10
- # -----------------------------------------------------------------------------
11
 
12
- # Django Secret Key (REQUIRED)
13
- # Generate a new secret key: python -c "from django.core.management.utils import get_random_secret_key; print(get_random_secret_key())"
14
- # Or use: python manage.py shell -c "from django.core.management.utils import get_random_secret_key; print(get_random_secret_key())"
15
- # WARNING: Never use the default value in production!
16
- SECRET_KEY=your-secret-key-here
17
 
18
- # HuggingFace API Token (REQUIRED)
19
- # Get your token from: https://huggingface.co/settings/tokens
20
- # Required for agent functionality that uses HuggingFace models
21
- HUGGINGFACEHUB_API_TOKEN=your-huggingface-api-token-here
22
-
23
- # -----------------------------------------------------------------------------
24
- # Debug and Development Settings
25
- # -----------------------------------------------------------------------------
26
-
27
- # Debug Mode
28
- # Set to True for development, False for production
29
- # When True: Shows detailed error pages, allows localhost access
30
- # When False: Shows generic error pages, requires ALLOWED_HOSTS to be set
31
- # Default: True
32
  DEBUG=True
33
 
34
- # -----------------------------------------------------------------------------
35
- # Host and CORS Configuration
36
- # -----------------------------------------------------------------------------
37
-
38
- # Allowed Hosts
39
- # Comma-separated list of host/domain names that this Django site can serve
40
- # Required for production (leave empty for development with DEBUG=True)
41
- # Example: grammo.kaeizen.dev,kaeizen.dev
42
- # Example: localhost,127.0.0.1 (for local development)
43
- # Default: [] (empty list, uses DEBUG=True fallback)
44
- ALLOWED_HOSTS=
45
-
46
- # CORS Allow All Origins
47
- # Set to True to allow all origins (development only)
48
- # Set to False or empty string to restrict origins (production)
49
- # When False, configure specific origins using django-cors-headers settings
50
- # Default: True (allows all origins)
51
- CORS_ALLOW_ALL_ORIGINS=True
52
-
53
- # CSRF Trusted Origins
54
- # Comma-separated list of trusted origins for CSRF protection
55
- # Include your frontend URL(s) here
56
- # Example: http://localhost:5173,http://localhost:3000
57
- # Example for production: https://grammo.kaeizen.dev,https://kaeizen.dev
58
- # Default: [] (empty list)
59
- CSRF_TRUSTED_ORIGINS=http://localhost:5173,http://localhost:3000
60
-
61
- # -----------------------------------------------------------------------------
62
- # Security Settings
63
- # -----------------------------------------------------------------------------
64
-
65
- # Session Cookie Security
66
- # Set to False for local development (no HTTPS)
67
- # Set to True for production (requires HTTPS)
68
- # When True, cookies are only sent over HTTPS connections
69
- # Default: False
70
- SESSION_COOKIE_SECURE=False
71
-
72
- # CSRF Cookie Security
73
- # Set to False for local development (no HTTPS)
74
- # Set to True for production (requires HTTPS)
75
- # When True, CSRF cookies are only sent over HTTPS connections
76
- # Default: False
77
- CSRF_COOKIE_SECURE=False
78
 
79
- # Secure SSL Redirect
80
- # Set to True in production to redirect all HTTP requests to HTTPS
81
- # Requires proper HTTPS configuration and valid SSL certificates
82
- # Set to False for local development (no HTTPS)
83
- # Default: False
84
- SECURE_SSL_REDIRECT=False
85
 
86
- # Secure Content Type No Sniff
87
- # Prevents browsers from MIME-sniffing the content-type
88
- # Set to True for production, False for development (optional)
89
- # Default: False
90
- SECURE_CONTENT_TYPE_NOSNIFF=False
91
-
92
- # -----------------------------------------------------------------------------
93
- # HSTS (HTTP Strict Transport Security) Settings
94
- # -----------------------------------------------------------------------------
95
- # WARNING: Only enable HSTS after ensuring HTTPS works correctly for all domains!
96
- # Once enabled, browsers will remember this for SECURE_HSTS_SECONDS seconds
97
- # Setting a value > 0 will enable HSTS, set to 0 to disable (recommended for development)
98
- # -----------------------------------------------------------------------------
99
-
100
- # HSTS Seconds
101
- # Set to 0 to disable HSTS (recommended for development)
102
- # Set to a positive value (e.g., 31536000 for 1 year) for production
103
- # Only enable after ensuring HTTPS works correctly
104
- # Default: 0 (disabled)
105
- SECURE_HSTS_SECONDS=0
106
-
107
- # HSTS Include Subdomains
108
- # Only used when SECURE_HSTS_SECONDS > 0
109
- # Set to True to apply HSTS to all subdomains
110
- # Set to False to apply only to the main domain
111
- # Default: False
112
- SECURE_HSTS_INCLUDE_SUBDOMAINS=False
113
-
114
- # HSTS Preload
115
- # Only used when SECURE_HSTS_SECONDS > 0
116
- # Set to True to allow inclusion in browser preload lists
117
- # See: https://hstspreload.org/
118
- # Default: False
119
- SECURE_HSTS_PRELOAD=False
120
-
121
- # -----------------------------------------------------------------------------
122
- # Example Production Configuration
123
- # -----------------------------------------------------------------------------
124
- # For production, use settings similar to these:
125
- #
126
- # DEBUG=False
127
  # ALLOWED_HOSTS=yourdomain.com,www.yourdomain.com
128
- # SESSION_COOKIE_SECURE=True
129
- # CSRF_COOKIE_SECURE=True
130
  # CSRF_TRUSTED_ORIGINS=https://yourdomain.com,https://www.yourdomain.com
131
- # SECURE_SSL_REDIRECT=True
132
- # SECURE_CONTENT_TYPE_NOSNIFF=True
133
- # SECURE_HSTS_SECONDS=31536000
134
- # SECURE_HSTS_INCLUDE_SUBDOMAINS=True
135
- # SECURE_HSTS_PRELOAD=True
136
- # CORS_ALLOW_ALL_ORIGINS=False
 
1
+ # Grammo Backend - Example .env
2
+ # Copy this file to .env and fill in the values as needed.
 
 
 
 
3
 
4
+ # --- Required ---
5
+ # Django Secret Key (generate one with the command in README)
6
+ SECRET_KEY=
7
 
8
+ # HuggingFace API Token (any of these will be picked up; preferred shown first)
9
+ HUGGINGFACEHUB_API_TOKEN=
10
+ # HF_TOKEN=
11
+ # HF_API_TOKEN=
 
12
 
13
+ # --- Core Runtime ---
14
+ # Debug mode (default: True)
 
 
 
 
 
 
 
 
 
 
 
 
15
  DEBUG=True
16
 
17
+ # App mode: "development" (default) or "production"
18
+ MODE=development
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
19
 
20
+ # Port used only when running `python app.py` (Hugging Face Spaces)
21
+ # PORT=7860
 
 
 
 
22
 
23
+ # --- Production-only ---
24
+ # When MODE=production, set these appropriately
25
+ # Comma-separated (no spaces)
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
26
  # ALLOWED_HOSTS=yourdomain.com,www.yourdomain.com
27
+
28
+ # Comma-separated full origins (scheme + host)
29
  # CSRF_TRUSTED_ORIGINS=https://yourdomain.com,https://www.yourdomain.com
30
+
31
+ # Notes:
32
+ # - Security and CORS flags are derived automatically from MODE in settings.py
33
+ # - Do not set SESSION_COOKIE_SECURE, CSRF_COOKIE_SECURE, CORS_ALLOW_ALL_ORIGINS, or SECURE_* directly
 
 
Dockerfile CHANGED
@@ -22,20 +22,23 @@ RUN pip install --no-cache-dir -r requirements.txt
22
  # Install specific transformers
23
  RUN pip install git+https://github.com/huggingface/transformers@8fb854cac869b42c87a7bd15d9298985c5aea96e
24
 
25
- RUN --mount=type=secret,id=SECRET_KEY,env=SECRET_KEY
26
- RUN --mount=type=secret,id=HUGGINGFACEHUB_API_TOKEN,env=HUGGINGFACEHUB_API_TOKEN
27
-
28
- RUN --mount=type=secret,id=DEBUG,env=DEBUG
29
- RUN --mount=type=secret,id=SESSION_COOKIE_SECURE,env=SESSION_COOKIE_SECURE
30
- RUN --mount=type=secret,id=CSRF_COOKIE_SECURE,env=CSRF_COOKIE_SECURE
31
- RUN --mount=type=secret,id=ALLOWED_HOSTS,env=ALLOWED_HOSTS
32
- RUN --mount=type=secret,id=SECURE_CONTENT_TYPE_NOSNIFF,env=SECURE_CONTENT_TYPE_NOSNIFF
33
- RUN --mount=type=secret,id=SECURE_SSL_REDIRECT,env=SECURE_SSL_REDIRECT
34
- RUN --mount=type=secret,id=SECURE_HSTS_SECONDS,env=SECURE_HSTS_SECONDS
35
- RUN --mount=type=secret,id=SECURE_HSTS_INCLUDE_SUBDOMAINS,env=SECURE_HSTS_INCLUDE_SUBDOMAINS
36
- RUN --mount=type=secret,id=SECURE_HSTS_PRELOAD,env=SECURE_HSTS_PRELOAD
37
- RUN --mount=type=secret,id=CORS_ALLOW_ALL_ORIGINS,env=CORS_ALLOW_ALL_ORIGINS
38
- RUN --mount=type=secret,id=CSRF_TRUSTED_ORIGINS,env=CSRF_TRUSTED_ORIGINS
 
 
 
39
 
40
  # Copy the entire backend directory
41
  COPY . .
 
22
  # Install specific transformers
23
  RUN pip install git+https://github.com/huggingface/transformers@8fb854cac869b42c87a7bd15d9298985c5aea96e
24
 
25
+ RUN --mount=type=secret,id=SECRET_KEY,mode=0444,required=true \
26
+ sh -c 'printf "SECRET_KEY=%s\n" "$(cat /run/secrets/SECRET_KEY)" > .env'
27
+
28
+ RUN --mount=type=secret,id=HUGGINGFACEHUB_API_TOKEN,mode=0444,required=true \
29
+ sh -c 'printf "HUGGINGFACEHUB_API_TOKEN=%s\n" "$(cat /run/secrets/HUGGINGFACEHUB_API_TOKEN)" >> .env'
30
+
31
+ RUN --mount=type=secret,id=MODE,mode=0444,required=true \
32
+ sh -c 'printf "MODE=%s\n" "$(cat /run/secrets/MODE)" >> .env'
33
+
34
+ RUN --mount=type=secret,id=DEBUG,mode=0444,required=true \
35
+ sh -c 'printf "DEBUG=%s\n" "$(cat /run/secrets/DEBUG)" >> .env'
36
+
37
+ RUN --mount=type=secret,id=ALLOWED_HOSTS,mode=0444,required=true \
38
+ sh -c 'printf "ALLOWED_HOSTS=%s\n" "$(cat /run/secrets/ALLOWED_HOSTS)" >> .env'
39
+
40
+ RUN --mount=type=secret,id=CSRF_TRUSTED_ORIGINS,mode=0444,required=true \
41
+ sh -c 'printf "CSRF_TRUSTED_ORIGINS=%s\n" "$(cat /run/secrets/CSRF_TRUSTED_ORIGINS)" >> .env'
42
 
43
  # Copy the entire backend directory
44
  COPY . .
README.md CHANGED
@@ -73,18 +73,22 @@ pip install -r requirements.txt
73
 
74
  ### 4. Set up environment variables
75
 
76
- Create a `.env` file in the `backend` directory:
77
 
78
  ```bash
79
- touch .env
80
  ```
81
 
82
- Add the following environment variables (see [Environment Variables](#environment-variables) section for details):
83
 
84
  ```env
 
85
  SECRET_KEY=your-secret-key-here
86
  HUGGINGFACEHUB_API_TOKEN=your-huggingface-api-token
 
 
87
  DEBUG=True
 
88
  ```
89
 
90
  To generate a Django secret key:
@@ -101,49 +105,51 @@ python manage.py migrate
101
 
102
  ## Environment Variables
103
 
104
- Create a `.env` file in the `backend` directory with the following variables:
105
 
106
- ### Required Variables
107
 
108
  ```env
109
  # Django Secret Key (generate one using the command above)
110
  SECRET_KEY=your-secret-key-here
111
 
112
- # HuggingFace API Token
113
  HUGGINGFACEHUB_API_TOKEN=your-huggingface-api-token
 
 
114
  ```
115
 
116
- ### Optional Development Variables
117
 
118
  ```env
119
  # Debug mode (default: True)
120
  DEBUG=True
121
 
122
- # Session security (default: False for development)
123
- SESSION_COOKIE_SECURE=False # Set to True in production (requires HTTPS)
124
- CSRF_COOKIE_SECURE=False # Set to True in production (requires HTTPS)
125
 
126
- # CORS settings
127
- CORS_ALLOW_ALL_ORIGINS=True # Set to False in production and specify origins
128
  ```
129
 
130
- ### Optional Production Variables
 
 
131
 
132
  ```env
133
- # Allowed hosts (comma-separated)
134
  ALLOWED_HOSTS=yourdomain.com,www.yourdomain.com
135
 
136
  # CSRF trusted origins (comma-separated)
137
  CSRF_TRUSTED_ORIGINS=https://yourdomain.com,https://www.yourdomain.com
138
-
139
- # Security settings
140
- SECURE_SSL_REDIRECT=True
141
- SECURE_CONTENT_TYPE_NOSNIFF=True
142
- SECURE_HSTS_SECONDS=31536000
143
- SECURE_HSTS_INCLUDE_SUBDOMAINS=True
144
- SECURE_HSTS_PRELOAD=True
145
  ```
146
 
 
 
 
 
 
 
147
  ## Running the Application
148
 
149
  ### Development Mode
@@ -323,12 +329,10 @@ The backend includes a `Dockerfile` configured for HuggingFace Spaces deployment
323
  1. **Set environment variables** in your Space settings:
324
  - `SECRET_KEY`
325
  - `HUGGINGFACEHUB_API_TOKEN`
 
326
  - `DEBUG=False`
327
  - `ALLOWED_HOSTS=your-space-name.hf.space`
328
- - `CORS_ALLOW_ALL_ORIGINS=False`
329
  - `CSRF_TRUSTED_ORIGINS=https://your-space-name.hf.space`
330
- - `SESSION_COOKIE_SECURE=True`
331
- - `CSRF_COOKIE_SECURE=True`
332
 
333
  2. **Push your code** to the Space repository
334
 
@@ -337,7 +341,8 @@ The backend includes a `Dockerfile` configured for HuggingFace Spaces deployment
337
  ### General Production Deployment
338
 
339
  1. Set production environment variables (see [Environment Variables](#environment-variables))
340
- 2. Set `DEBUG=False`
 
341
  3. Configure a proper database (PostgreSQL recommended)
342
  4. Set up Redis or another cache backend for sessions
343
  5. Use a production ASGI server (Uvicorn with multiple workers or Gunicorn with Uvicorn workers)
 
73
 
74
  ### 4. Set up environment variables
75
 
76
+ Create a `.env` file in the `backend` directory (or copy from the example):
77
 
78
  ```bash
79
+ cp .env.example .env # or: touch .env
80
  ```
81
 
82
+ At minimum, set the variables below (see [Environment Variables](#environment-variables) for details):
83
 
84
  ```env
85
+ # Required
86
  SECRET_KEY=your-secret-key-here
87
  HUGGINGFACEHUB_API_TOKEN=your-huggingface-api-token
88
+
89
+ # Common
90
  DEBUG=True
91
+ MODE=development # change to "production" for deployment
92
  ```
93
 
94
  To generate a Django secret key:
 
105
 
106
  ## Environment Variables
107
 
108
+ Create a `.env` file in the `backend` directory. The backend loads variables from this file using `python-dotenv`.
109
 
110
+ ### Required
111
 
112
  ```env
113
  # Django Secret Key (generate one using the command above)
114
  SECRET_KEY=your-secret-key-here
115
 
116
+ # HuggingFace API Token (any of these will be picked up; preferred shown first)
117
  HUGGINGFACEHUB_API_TOKEN=your-huggingface-api-token
118
+ # HF_TOKEN=your-huggingface-api-token
119
+ # HF_API_TOKEN=your-huggingface-api-token
120
  ```
121
 
122
+ ### Core Runtime
123
 
124
  ```env
125
  # Debug mode (default: True)
126
  DEBUG=True
127
 
128
+ # App mode: "development" (default) or "production"
129
+ MODE=development
 
130
 
131
+ # Port only used when running `python app.py` (Hugging Face Spaces)
132
+ # PORT=7860
133
  ```
134
 
135
+ ### Production-only
136
+
137
+ When `MODE=production`, the following become relevant:
138
 
139
  ```env
140
+ # Allowed hosts (comma-separated, no spaces)
141
  ALLOWED_HOSTS=yourdomain.com,www.yourdomain.com
142
 
143
  # CSRF trusted origins (comma-separated)
144
  CSRF_TRUSTED_ORIGINS=https://yourdomain.com,https://www.yourdomain.com
 
 
 
 
 
 
 
145
  ```
146
 
147
+ Notes:
148
+ - Most security and CORS flags are derived automatically from `MODE` in `backend/settings.py`:
149
+ - In development: permissive defaults for local usage
150
+ - In production: `CORS_ALLOW_ALL_ORIGINS=False`, secure cookies, HSTS, content type nosniff, and SSL redirect are enabled
151
+ - Do not set `SESSION_COOKIE_SECURE`, `CSRF_COOKIE_SECURE`, `CORS_ALLOW_ALL_ORIGINS`, or `SECURE_*` directly via env; they are computed from `MODE`.
152
+
153
  ## Running the Application
154
 
155
  ### Development Mode
 
329
  1. **Set environment variables** in your Space settings:
330
  - `SECRET_KEY`
331
  - `HUGGINGFACEHUB_API_TOKEN`
332
+ - `MODE=production`
333
  - `DEBUG=False`
334
  - `ALLOWED_HOSTS=your-space-name.hf.space`
 
335
  - `CSRF_TRUSTED_ORIGINS=https://your-space-name.hf.space`
 
 
336
 
337
  2. **Push your code** to the Space repository
338
 
 
341
  ### General Production Deployment
342
 
343
  1. Set production environment variables (see [Environment Variables](#environment-variables))
344
+ - `MODE=production`, `DEBUG=False`
345
+ - `ALLOWED_HOSTS` and `CSRF_TRUSTED_ORIGINS`
346
  3. Configure a proper database (PostgreSQL recommended)
347
  4. Set up Redis or another cache backend for sessions
348
  5. Use a production ASGI server (Uvicorn with multiple workers or Gunicorn with Uvicorn workers)
backend/settings.py CHANGED
@@ -30,41 +30,47 @@ SECRET_KEY = os.environ.get("SECRET_KEY", "local-dev-secret")
30
  # SECURITY WARNING: don't run with debug turned on in production!
31
  DEBUG = os.environ.get("DEBUG", "True") == "True"
32
 
33
- ALLOWED_HOSTS = [
 
 
34
  origin.strip()
35
  for origin in os.environ.get("ALLOWED_HOSTS", "").split(",")
36
  if origin.strip()
37
- ] if os.environ.get("ALLOWED_HOSTS") else []
38
 
39
  CORS_ALLOW_CREDENTIALS = True
40
- CORS_ALLOW_ALL_ORIGINS = os.environ.get("CORS_ALLOW_ALL_ORIGINS", "True") == "True"
41
 
42
 
43
  SESSION_COOKIE_HTTPONLY = True
44
- SESSION_COOKIE_SECURE = os.environ.get("SESSION_COOKIE_SECURE", "False") == "True" # use False only for local dev (no HTTPS)
45
  SESSION_EXPIRE_AT_BROWSER_CLOSE = True
46
  SESSION_COOKIE_AGE = 60 * 60 * 24 # 1 day
47
 
48
  CSRF_COOKIE_HTTPONLY = True
49
- CSRF_COOKIE_SECURE = os.environ.get("CSRF_COOKIE_SECURE", "False") == "True"
50
  CSRF_TRUSTED_ORIGINS = [
51
  origin.strip()
52
  for origin in os.environ.get("CSRF_TRUSTED_ORIGINS", "").split(",")
53
  if origin.strip()
54
- ]
 
 
 
 
55
 
56
- SECURE_SSL_REDIRECT = os.environ.get("SECURE_SSL_REDIRECT", "False") == "True"
57
 
58
- SECURE_CONTENT_TYPE_NOSNIFF = os.environ.get("SECURE_CONTENT_TYPE_NOSNIFF", "False") == "True"
59
 
60
  # HSTS settings - only enable in production with proper HTTPS configuration
61
  # WARNING: Once enabled, browsers will remember this for SECURE_HSTS_SECONDS seconds
62
  # Only enable after ensuring HTTPS works correctly for all domains
63
  # Set to 0 to disable HSTS (default for development), or set a positive value (e.g., 31536000 for 1 year) for production
64
- SECURE_HSTS_SECONDS = int(os.environ.get("SECURE_HSTS_SECONDS", "0"))
65
- if SECURE_HSTS_SECONDS > 0:
66
- SECURE_HSTS_INCLUDE_SUBDOMAINS = os.environ.get("SECURE_HSTS_INCLUDE_SUBDOMAINS", "False") == "True"
67
- SECURE_HSTS_PRELOAD = os.environ.get("SECURE_HSTS_PRELOAD", "False") == "True"
68
 
69
 
70
  # Allow embedding in an iframe only from Hugging Face Spaces (for integration)
 
30
  # SECURITY WARNING: don't run with debug turned on in production!
31
  DEBUG = os.environ.get("DEBUG", "True") == "True"
32
 
33
+ MODE = os.environ.get("MODE", "development")
34
+
35
+ ALLOWED_HOSTS =[
36
  origin.strip()
37
  for origin in os.environ.get("ALLOWED_HOSTS", "").split(",")
38
  if origin.strip()
39
+ ] if MODE == 'production' else []
40
 
41
  CORS_ALLOW_CREDENTIALS = True
42
+ CORS_ALLOW_ALL_ORIGINS = False if MODE == 'production' else True
43
 
44
 
45
  SESSION_COOKIE_HTTPONLY = True
46
+ SESSION_COOKIE_SECURE = False if MODE == 'production' else True # use False only for local dev (no HTTPS)
47
  SESSION_EXPIRE_AT_BROWSER_CLOSE = True
48
  SESSION_COOKIE_AGE = 60 * 60 * 24 # 1 day
49
 
50
  CSRF_COOKIE_HTTPONLY = True
51
+ CSRF_COOKIE_SECURE = False if MODE == 'production' else True
52
  CSRF_TRUSTED_ORIGINS = [
53
  origin.strip()
54
  for origin in os.environ.get("CSRF_TRUSTED_ORIGINS", "").split(",")
55
  if origin.strip()
56
+ ] if MODE == 'production' else [
57
+ 'http://localhost:5173',
58
+ 'http://localhost:4173',
59
+ 'http://localhost:3000'
60
+ ]
61
 
62
+ SECURE_SSL_REDIRECT = False if MODE == 'production' else True
63
 
64
+ SECURE_CONTENT_TYPE_NOSNIFF = False if MODE == 'production' else True
65
 
66
  # HSTS settings - only enable in production with proper HTTPS configuration
67
  # WARNING: Once enabled, browsers will remember this for SECURE_HSTS_SECONDS seconds
68
  # Only enable after ensuring HTTPS works correctly for all domains
69
  # Set to 0 to disable HSTS (default for development), or set a positive value (e.g., 31536000 for 1 year) for production
70
+ SECURE_HSTS_SECONDS = 31536000 if MODE == 'production' else 0
71
+ if MODE == 'production':
72
+ SECURE_HSTS_INCLUDE_SUBDOMAINS = True
73
+ SECURE_HSTS_PRELOAD = True
74
 
75
 
76
  # Allow embedding in an iframe only from Hugging Face Spaces (for integration)