You can distinguish between the actual method using request.method.
I assume that you want to:
- Render a template when the route is triggered with
GETmethod - Read form inputs and register a user if route is triggered with
POST
So your case is similar to the one described in the docs: Flask Quickstart – HTTP Methods
import flask
app = flask.Flask('your_flask_env')
@app.route('/register', methods=['GET', 'POST'])
def register():
if flask.request.method == 'POST':
username = flask.request.values.get('user') # Your form's
password = flask.request.values.get('pass') # input names
your_register_routine(username, password)
else:
# You probably don't have args at this route with GET
# method, but if you do, you can access them like so:
yourarg = flask.request.args.get('argname')
your_register_template_rendering(yourarg)