Getting started with Flask

The below gets you the route to which a definition is routed to.

from filename import appapp.url_map


Simple page rendering


Structure - server file
static - contains css, js, images and library files
template - contains html files

Post request/Get request

from flask import request
@app.route('/form-example', methods=['GET', 'POST'])

Get parameters



Default Routing

Static route is a default route where you can place all the images. Run python as usual, go to localhost:8080/static/flasklogo.png to see the static file (flasklogo.png).

Error route handling


Debug Mode

MVC model

Models (“M” in MVC): Databases

Template (“Views” in MVC): Jinja2

Views (“Controller” in MVC): Generates Http request and URL mapping

Add URL links

<link rel="stylesheet" type="text/css" href="{{url_for('static', filename='css/mycss.css')}}"><a href="{{ url_for('link') }}">LINK</a>


{% block title%} 
#common styling exported from view.html, you can only deal with content here
{% endblock %}



Love podcasts or audiobooks? Learn on the go with our new app.

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store