I am making a simple Flask web-app.
- It will simply take text input.
- The user will type in the text and click on the submit button.
I have created the textarea inside Form HTML tag for text input. And I have a Submit button created using a hyperlink tag .
How can I access the text inside the textarea when the Submit is clicked?
Note: I do not want to use the default submit option available within the form tag.
HTML for Textarea :
<form action="{{ url_for('publish') }}" method="post">
<textarea name="text" class="form-control" rows="1" placeholder="Enter your message"></textarea>
</form>
HTML for Submit button :
<a href="{{ url_for('publish') }}" method="post"> Submit </a>
Flask code to retrieve textarea input from user :
@app.route('/publish', methods=['GET', 'POST'])
def publish():
message = request.form['text']
print(message)
print('well')
return render_template('index.html')