#Barebones App #Access Request Data #Useful Plugins: Rin Ted .Co M
The document provides a cheat sheet and quick reference for Flask, a Python-based web application framework. It summarizes key Flask concepts like creating a basic app, routing, accessing request data, redirects, templates, JSON responses, configuration, plugins, and session handling. Useful links are also included for additional Flask resources.
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0 ratings0% found this document useful (0 votes)
3K views
#Barebones App #Access Request Data #Useful Plugins: Rin Ted .Co M
The document provides a cheat sheet and quick reference for Flask, a Python-based web application framework. It summarizes key Flask concepts like creating a basic app, routing, accessing request data, redirects, templates, JSON responses, configuration, plugins, and session handling. Useful links are also included for additional Flask resources.
#JSON Responses app.config['SECRET_KEY'] = 'any random string' #must be set to use sessions
import jsonify #set session
@app.route('/login_success') @app.route('/returnstuff') def login_success(): m co def returnstuff(): session['key_name'] = 'key_value' #stores a secure cookie in browser num_list = [1,2,3,4,5] d. te num_dict = {'numbers' : num_list, 'name' : 'Numbers'} return redirect(url_for('index')) i n #returns {'output' : {'numbers' : [1,2,3,4,5], 'name' : 'Numbers'}} #read session y pr return jsonify({'output' : num_dict}) t et @app.route('/') def index(): r ://p if 'key_name' in session: #session exists and has key ttp session_var = session['key_value'] else: #session does not exist h