I have my python code where I use html file. Please see below code:
@app.route('/',endpoint='buf')
def index():
page = """
<DOCTYPE! html>
<html lang="en-US">
<head>
<title>Hello World Page</title>
<meta charset=utf-8">
</head>
<body>
<form action="/hello" method="GET">
First: <input type="text" name="fname"><br>
Last name: <input type="text" name="lname"><br>
<input type="submit" value="Submit">
</form>
</body>
</html>
"""
return page
@app.route('/hello',endpoint="new",methods=['GET'])
def login():
return 'hello %s ' % (request.form['fname'])
This gives me an html page , which has a form with two fields and a submit button. I use virtual env to run this.
Now I want to get the fields first name and last name in my program so that when user click submit I want to display Hello "first name""last name"
Purpose :- to learn how to get the html element values when provided with a code In a python file.