1
<html>
  <head>
  </head>
<body>
<form>
<select multiple="multiple" 
<option value="Hello">Hello</option>
</select>
</form>
</body>
</html>

I am using postgresql database in which I have table with one column and one row saying 'Hello'

I want to pull that data and display it as selection option in html form using FLASK.

Can anyone help me please, Thanks in advance

2
  • 1
    It's actually opposite to the above posting, I need data from database(postgresql) to be posted in select html form not by using php but by using python-flask Commented May 29, 2018 at 23:21
  • Ah gotcha, flag removed! Commented May 29, 2018 at 23:24

1 Answer 1

1

It seems like you need to read Flask's Quickstart to learn some basic.

Here is a minimal application that meets your needs.

View function:

from flask import Flask, render_template

app = Flask(__name__)

@app.route('/')
def index():
    items = get_your_data_from_db()
    return render_template('index.html', items=items)

templates/index.html

<html>
  <head>
  </head>
<body>
<form>
<select multiple="multiple">
{% for item in items %}
<option value="{{ item.field_name }}">{{ item.field_name }}</option>
{% endfor %}
</select>
</form>
</body>
</html>
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.