Answer the question
In order to leave comments, you need to log in
How to pull data from a .txt file into a dropdown form?
I want to create a web form using flask, js and html:
index.html
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Python Flask Dynamic Select Box using Flask, JS and txt </title>
</h2></p>
<pre>
{{ text }}
</pre>
</body>
</html>
from flask import Flask, render_template
app = Flask(__name__)
@app.route('/')
def index():
with open('QA.txt', 'r', encoding = 'utf-8') as f:
return render_template('index.html', text=f.read())
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question