Spaces:
Paused
Paused
Create app.py
Browse files
app.py
ADDED
|
@@ -0,0 +1,29 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
from flask import Flask, render_template, request
|
| 2 |
+
from llm import get_prompt, get_responce
|
| 3 |
+
|
| 4 |
+
app = Flask(__name__)
|
| 5 |
+
|
| 6 |
+
# Assume your question generation logic is already defined
|
| 7 |
+
def generate_questions(question_type):
|
| 8 |
+
if question_type == 'mcq':
|
| 9 |
+
return ["What is the capital of France?", "Choose the correct answer from four options."]
|
| 10 |
+
elif question_type == 'fill_blank':
|
| 11 |
+
return ["The sun rises in the ____.", "Fill in the correct word."]
|
| 12 |
+
elif question_type == 'short_answer':
|
| 13 |
+
return ["Explain the process of photosynthesis."]
|
| 14 |
+
else:
|
| 15 |
+
return ["No questions available for the selected type."]
|
| 16 |
+
|
| 17 |
+
@app.route('/')
|
| 18 |
+
def home():
|
| 19 |
+
return render_template('index.html')
|
| 20 |
+
|
| 21 |
+
@app.route('/get_questions', methods=['POST'])
|
| 22 |
+
def get_questions():
|
| 23 |
+
question_type = request.form['question_type']
|
| 24 |
+
prompt, seed = get_prompt(question_type)
|
| 25 |
+
questions = get_responce(prompt)
|
| 26 |
+
return render_template('questions.html', questions=questions, question_type=questions[0]["question_type"], seed = seed)
|
| 27 |
+
|
| 28 |
+
if __name__ == '__main__':
|
| 29 |
+
app.run(debug=True)
|