In here

<!DOCTYPE html> <html> <body> <h3>Enter Your Name</h3> <form method="post"> <input type="text" name="username" required> <br><br> <input type="submit" value="Submit"> </form> </body> </html> from flask import Flask, request, render_template app = Flask(__name__) @app.route('/login', methods=['GET', 'POST']) def login(): if request.method == 'POST': name = request.form['username'] return f"Hello {name}, POST request received" return render_template('name.html') if __name__ == '__main__': app.run(debug=True)

When the request is 'GET' then the render_template('name.html') runs but how GET request is made? we do create request method s POST in the html form but we did not do anything when '/login' is called initially?

Ronaka Samaraweera's user avatar

1

When the browser fetches a URL, or the curl command line or other command lines to fetch URLs, it makes a GET request to the server.

So, to make a GET request to obtain the login form, simply enter the URL https://.../login (where the ... is the base URL to your API) in your browser.

J Earls's user avatar

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.