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 O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.