RewardApp / trash /app.py
Mhdeusi's picture
Rename app.py to trash/app.py
f6c3965 verified
from flask import Flask, render_template, jsonify, request
import json
import os
app = Flask(__name__)
@app.route('/')
def index():
return render_template('index.html')
@app.route('/api/lesson/<int:day>')
def get_lesson(day):
try:
with open(f'data/lesson_day{day}.json', 'r', encoding='utf-8') as f:
return jsonify(json.load(f))
except FileNotFoundError:
return jsonify({'error': 'Lesson not found'}), 404
@app.route('/api/quiz/<int:day>')
def get_quiz(day):
try:
with open(f'data/quiz_day{day}.json', 'r', encoding='utf-8') as f:
return jsonify(json.load(f))
except FileNotFoundError:
return jsonify({'error': 'Quiz not found'}), 404
@app.route('/api/exercise/<int:day>')
def get_exercise(day):
try:
with open(f'data/exercise_day{day}.json', 'r', encoding='utf-8') as f:
return jsonify(json.load(f))
except FileNotFoundError:
return jsonify({'error': 'Exercise not found'}), 404
if __name__ == '__main__':
app.run(debug=True, port=5000)