From d1e0e1a161de86d8aae23ce9284e47db2e108fe1 Mon Sep 17 00:00:00 2001 From: admin Date: Wed, 25 Feb 2026 13:23:22 -0800 Subject: [PATCH] index.html and widgets --- app.py | 50 +++++++++++++++++++++++++++++++++++++++----- templates/index.html | 31 +++++++++++++++++++++++++++ 2 files changed, 76 insertions(+), 5 deletions(-) create mode 100644 templates/index.html diff --git a/app.py b/app.py index 5d20a01..29565bd 100644 --- a/app.py +++ b/app.py @@ -1,12 +1,52 @@ -from flask import Flask - +from flask import Flask, request, render_template, send_file +import json +from io import BytesIO +import zipfile +from bs4 import BeautifulSoup app = Flask(__name__) -@app.route('/') -def hello_world(): # put application's code here - return 'Hello World!' +@app.route('/', methods=['GET', 'POST']) +def index(): + reference = '' + version = '' + verse = '' + error = '' + if request.method == 'POST': + reference = request.form.get('scripture_reference') + version = request.form.get('version') + + # Map version to ESV Bible ID + bible_id = { + 'NRSV': 'nrs', + 'NIV': 'niv', + 'NLT': 'nlt' + }.get(version) + + if bible_id and reference: + # ESV API endpoint + api_key = 'YOUR_ESV_API_KEY' # Replace with your actual API key + url = f'https://api.esv.org/v2/verse?verse={reference}&bible={bible_id}&key={api_key}' + + try: + response = request.get(url) + response.raise_for_status() + data = response.json() + + if data['verses']: + verse = data['verses'][0]['text'] + else: + error = "Verse not found." + except request.RequestException as e: + error = f"Error fetching verse: {str(e)}" + else: + error = "Please provide both a reference and a version." + + # Print to stdout + print(f"Reference: {reference}, Version: {version}, Verse: {verse}, Error: {error}") + + return render_template('index.html', reference=reference, version=version, verse=verse, error=error) if __name__ == '__main__': app.run() diff --git a/templates/index.html b/templates/index.html new file mode 100644 index 0000000..d59d657 --- /dev/null +++ b/templates/index.html @@ -0,0 +1,31 @@ + + + + + Scripture Reference Tool + + +

Scripture Reference Tool

+
+
+

+ +
+

+ + +
+ + {% if verse %} +

Verse:

+

{{ verse }}

+ {% elif error %} +

Error:

+

{{ error }}

+ {% endif %} + + \ No newline at end of file