I am trying to make a basic webapp, which takes two basic inputs from the user called "phrase" (The word you want the text to be searched in) and "letters" (The letters you want to look for inside the "phrase" input). I have used Python (Flask) and a bit of HTML to make it. Everything was fine until I tried to connect the input values from the HTML form to Python using the "request" object of flask. I have attached the Python and HTML code along with the error at the client side and the error at Visual Studio Code, I tried asking my friends for the solution but they were not sure about it either. Python code-
app = Flask(__name__)
@app.route('/')
def flask_hello():
return 'Please go to: http://127.0.0.1:5000/entry'
@app.route('/search4', methods=['POST'])
def do_search(phrase,letters) -> str:
phrase = request.form['phrase']
letters = request.form['letters']
return str(set(letters)).intersection(str(phrase))
# return(common)
@app.route ('/entry')
def entry_page() -> 'html':
return render_template('entry.html',
the_title='Welcome to search4letters on the web!')
app.run(debug=True)
HTML Code-
{% extends 'base.html' %}
{% block body %}
<h2> {{ the_tile }}</h2>
<form method='POST' action='/search4'>
<table>
<p>Use this form to submit a search request</p>
<tr><td>Phrase:</td><td><input name='phrase' type='TEXT' width='60'></td></tr>
<tr><td>Letters:</td><td><input name='letters' type='TEXT' value='aeiou'></td></tr>
</table>
<p> When you're ready, click this button:</p>
<p><input value='Do it!!' type='submit'></p>
</form>
Error at the client side and VS code is attached too-
I am not sure why this happening, I am not sure if it is a really stupid thing and I am not able to figure it out, I tried looking for a solution but was not able to find any. Hopefully you guys can help me with this, thanks in Advance! Have a great day ahead.