Creating the application routes

Now we can start creating the routes. First, we are going to add the root route:

@app.route('/')def home():         config = read_config()    get_oauth_token(config)    url = f'{config.authorize_url}?oauth_token=    {req_token.oauth_token}'    return render_template('index.html', link=url)

We read the configuration file and pass it the get_oauth_token function. This function will populate the global variable req_token with the oauth_token value; we need this token to start the authorization process. Then we build the authorization URL with the values of authorize_url obtained from the configuration file and the OAuth request token.

Lastly, we use the render_template to render the index.html template that we created and we also ...

Get Python Programming Blueprints now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.