Update app.py
Browse files
app.py
CHANGED
@@ -48,11 +48,20 @@ def generate_quiz(context):
|
|
48 |
@app.route("/", methods=["GET", "POST"])
|
49 |
def generate_quiz_page():
|
50 |
if request.method == "POST":
|
51 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
52 |
response = generate_quiz(context)
|
53 |
|
54 |
-
|
55 |
-
|
56 |
|
57 |
|
58 |
quiz_html = f"""
|
|
|
48 |
@app.route("/", methods=["GET", "POST"])
|
49 |
def generate_quiz_page():
|
50 |
if request.method == "POST":
|
51 |
+
if request.content_type == 'application/json':
|
52 |
+
data = request.get_json()
|
53 |
+
context = data.get("context")
|
54 |
+
if context is None:
|
55 |
+
return jsonify({"error": "Missing 'context' parameter"}), 400
|
56 |
+
else:
|
57 |
+
context = request.form.get("context")
|
58 |
+
if context is None:
|
59 |
+
return jsonify({"error": "Missing 'context' parameter"}), 400
|
60 |
+
|
61 |
response = generate_quiz(context)
|
62 |
|
63 |
+
if request.content_type == 'application/json':
|
64 |
+
return jsonify(response)
|
65 |
|
66 |
|
67 |
quiz_html = f"""
|