mou3az commited on
Commit
7168597
·
verified ·
1 Parent(s): 6fd811d

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +120 -4
app.py CHANGED
@@ -47,7 +47,7 @@ def generate_quiz_page():
47
  if request.method == "POST":
48
  context = request.form.get("context")
49
  response = generate_quiz(context)
50
-
51
  quiz_html = f"""
52
  <!DOCTYPE html>
53
  <html lang="en">
@@ -55,25 +55,139 @@ def generate_quiz_page():
55
  <meta charset="UTF-8">
56
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
57
  <title>Generated Quiz</title>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
58
  </head>
59
  <body>
60
  <h2>Generated Quiz</h2>
61
  <pre>{response}</pre>
62
  <p><a href="/">Back to generate another quiz</a></p>
 
 
 
 
 
 
63
  </body>
64
  </html>
65
  """
66
-
67
  return quiz_html
68
-
69
  # Default GET request handling
70
- return """
71
  <!DOCTYPE html>
72
  <html lang="en">
73
  <head>
74
  <meta charset="UTF-8">
75
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
76
  <title>Generate Quiz</title>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
77
  </head>
78
  <body>
79
  <h2>Generate Quiz</h2>
@@ -86,5 +200,7 @@ def generate_quiz_page():
86
  </html>
87
  """
88
 
 
 
89
  if __name__ == "__main__":
90
  app.run(debug=True)
 
47
  if request.method == "POST":
48
  context = request.form.get("context")
49
  response = generate_quiz(context)
50
+
51
  quiz_html = f"""
52
  <!DOCTYPE html>
53
  <html lang="en">
 
55
  <meta charset="UTF-8">
56
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
57
  <title>Generated Quiz</title>
58
+ <style>
59
+ body {{
60
+ font-family: Arial, sans-serif;
61
+ background-color: #f0f0f0; /* Light grey background */
62
+ color: #333; /* Dark grey text color */
63
+ margin: 20px;
64
+ }}
65
+ h2 {{
66
+ background-color: #ffc107; /* Yellow background for heading */
67
+ padding: 10px;
68
+ border-radius: 5px;
69
+ }}
70
+ form {{
71
+ background-color: #fff; /* White background for form */
72
+ padding: 20px;
73
+ border-radius: 5px;
74
+ box-shadow: 0 0 10px rgba(0, 0, 0, 0.1); /* Light shadow effect */
75
+ }}
76
+ label {{
77
+ display: block;
78
+ margin-bottom: 10px;
79
+ }}
80
+ textarea {{
81
+ width: 100%;
82
+ padding: 10px;
83
+ border: 1px solid #ccc;
84
+ border-radius: 4px;
85
+ resize: vertical; /* Allow vertical resizing of textarea */
86
+ }}
87
+ input[type="submit"] {{
88
+ background-color: #ffc107; /* Yellow background for submit button */
89
+ color: #333; /* Dark grey text color */
90
+ border: none;
91
+ padding: 10px 20px;
92
+ cursor: pointer;
93
+ border-radius: 4px;
94
+ }}
95
+ input[type="submit"]:hover {{
96
+ background-color: #ffca28; /* Lighter yellow on hover */
97
+ }}
98
+ pre {{
99
+ background-color: #fff; /* White background for quiz response */
100
+ padding: 20px;
101
+ border-radius: 5px;
102
+ box-shadow: 0 0 10px rgba(0, 0, 0, 0.1); /* Light shadow effect */
103
+ }}
104
+ a {{
105
+ color: #ffc107; /* Yellow text color for links */
106
+ text-decoration: none;
107
+ }}
108
+ a:hover {{
109
+ text-decoration: underline; /* Underline on hover */
110
+ }}
111
+ </style>
112
  </head>
113
  <body>
114
  <h2>Generated Quiz</h2>
115
  <pre>{response}</pre>
116
  <p><a href="/">Back to generate another quiz</a></p>
117
+ <h2>Generate Quiz</h2>
118
+ <form action="/" method="post">
119
+ <label for="context">Context:</label><br>
120
+ <textarea id="context" name="context" rows="4" cols="50" required></textarea><br><br>
121
+ <input type="submit" value="Generate Quiz">
122
+ </form>
123
  </body>
124
  </html>
125
  """
126
+
127
  return quiz_html
128
+
129
  # Default GET request handling
130
+ default_html = """
131
  <!DOCTYPE html>
132
  <html lang="en">
133
  <head>
134
  <meta charset="UTF-8">
135
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
136
  <title>Generate Quiz</title>
137
+ <style>
138
+ body {
139
+ font-family: Arial, sans-serif;
140
+ background-color: #f0f0f0; /* Light grey background */
141
+ color: #333; /* Dark grey text color */
142
+ margin: 20px;
143
+ }
144
+ h2 {
145
+ background-color: #ffc107; /* Yellow background for heading */
146
+ padding: 10px;
147
+ border-radius: 5px;
148
+ }
149
+ form {
150
+ background-color: #fff; /* White background for form */
151
+ padding: 20px;
152
+ border-radius: 5px;
153
+ box-shadow: 0 0 10px rgba(0, 0, 0, 0.1); /* Light shadow effect */
154
+ }
155
+ label {
156
+ display: block;
157
+ margin-bottom: 10px;
158
+ }
159
+ textarea {
160
+ width: 100%;
161
+ padding: 10px;
162
+ border: 1px solid #ccc;
163
+ border-radius: 4px;
164
+ resize: vertical; /* Allow vertical resizing of textarea */
165
+ }
166
+ input[type="submit"] {
167
+ background-color: #ffc107; /* Yellow background for submit button */
168
+ color: #333; /* Dark grey text color */
169
+ border: none;
170
+ padding: 10px 20px;
171
+ cursor: pointer;
172
+ border-radius: 4px;
173
+ }
174
+ input[type="submit"]:hover {
175
+ background-color: #ffca28; /* Lighter yellow on hover */
176
+ }
177
+ pre {
178
+ background-color: #fff; /* White background for quiz response */
179
+ padding: 20px;
180
+ border-radius: 5px;
181
+ box-shadow: 0 0 10px rgba(0, 0, 0, 0.1); /* Light shadow effect */
182
+ }
183
+ a {
184
+ color: #ffc107; /* Yellow text color for links */
185
+ text-decoration: none;
186
+ }
187
+ a:hover {
188
+ text-decoration: underline; /* Underline on hover */
189
+ }
190
+ </style>
191
  </head>
192
  <body>
193
  <h2>Generate Quiz</h2>
 
200
  </html>
201
  """
202
 
203
+ return default_html
204
+
205
  if __name__ == "__main__":
206
  app.run(debug=True)