from flask import Flask, render_template, redirect, url_for from botocore.exceptions import ClientError import database application = Flask(__name__) application.config.from_pyfile("config.py") @application.route("/") def index(): try: easy = database.get_random_question_difficulty(1) medium = database.get_random_question_difficulty(2) hard = database.get_random_question_difficulty(3) return render_template( "index.html", title="Quiz The Word", easy=easy, medium=medium, hard=hard, ) except ClientError as e: return e.response["Error"]["Message"] except Exception as e: return str(e) @application.route("/question/") def question(question_index): try: item_count = database.get_question_count() if question_index < item_count: item = database.get_question(question_index) return render_template( "index.html", title="Bible Trivia", question=item["Question"], answer=item["Answer"], addresses=item["Address"], category=item["Category"], difficulty=item["Difficulty"], ) else: return "

Question not found.

" except ClientError as e: return e.response["Error"]["Message"] except Exception as e: return str(e) if __name__ == "__main__": application.run()