Teddy Xinyuan Chen commited on
Commit
c483669
·
1 Parent(s): faba05c

2024-10-08T21-49-00Z

Browse files
embed-hf-space.html ADDED
@@ -0,0 +1,11 @@
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <!DOCTYPE html>
2
+ <html lang="en">
3
+ <head>
4
+ <meta charset="UTF-8">
5
+ <meta name="viewport" content="width=device-width, initial-scale=1.0">
6
+ <title>Embed HF Space</title>
7
+ </head>
8
+ <body>
9
+ <iframe src="https://tddschn-mq-quiz.hf.space/" width="100%" height="100%" style="border:none;"></iframe>
10
+ </body>
11
+ </html>
src/quizsite/middleware.py ADDED
@@ -0,0 +1,12 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from django.http import HttpResponse
2
+
3
+
4
+ class CSPMiddleware:
5
+ def __init__(self, get_response):
6
+ self.get_response = get_response
7
+
8
+ def __call__(self, request):
9
+ response = self.get_response(request)
10
+ response["Content-Security-Policy"] = "frame-ancestors 'self' https://*.huggingface.com https://*.teddysc.me;"
11
+ response["X-Frame-Options"] = "ALLOW-FROM https://*.huggingface.com https://*.teddysc.me"
12
+ return response
src/quizsite/settings.py CHANGED
@@ -181,3 +181,24 @@ STATIC_ROOT = os.path.join(BASE_DIR, "staticfiles")
181
  # https://docs.djangoproject.com/en/4.1/ref/settings/#default-auto-field
182
 
183
  DEFAULT_AUTO_FIELD = "django.db.models.BigAutoField"
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
181
  # https://docs.djangoproject.com/en/4.1/ref/settings/#default-auto-field
182
 
183
  DEFAULT_AUTO_FIELD = "django.db.models.BigAutoField"
184
+
185
+ ALLOWED_HOSTS = [
186
+ "localhost",
187
+ "mq-django-quiz-app.vercel.app",
188
+ "mq-quiz.teddysc.me",
189
+ "teddysc.me",
190
+ "g.teddysc.me",
191
+ "tddschn-mq-quiz.hf.space",
192
+ "huggingface.com", # Add this line
193
+ ]
194
+
195
+ CSRF_TRUSTED_ORIGINS = [
196
+ "http://localhost:8000",
197
+ "https://mq-django-quiz-app.vercel.app",
198
+ "https://mq-quiz.teddysc.me",
199
+ "https://teddysc.me",
200
+ "https://tddschn-mq-quiz.hf.space",
201
+ "http://tddschn-mq-quiz.hf.space",
202
+ "https://*.teddysc.me", # Add this line
203
+ "https://*.huggingface.com", # Add this line
204
+ ]