Skip to Main Content
Python Programming Blueprints
book

Python Programming Blueprints

by Daniel Furtado, Marcus Pennington
February 2018
Intermediate to advanced content levelIntermediate to advanced
456 pages
9h 56m
English
Packt Publishing
Content preview from Python Programming Blueprints

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 ...

Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Intelligent Projects Using Python

Intelligent Projects Using Python

Santanu Pattanayak, Manohar Swamynathan
Flask Blueprints

Flask Blueprints

Joël Perras
Matplotlib for Python Developers - Second Edition

Matplotlib for Python Developers - Second Edition

Aldrin Yim, Claire Chung, Allen Yu

Publisher Resources

ISBN: 9781786468161Supplemental Content