User Stream

[user_stream.html] {% extends “stream.html” %} {% block content %} <div class=”row”> <div class=”grid-25″> <h1>{{ user.username }}</h1> </div> <div class=”grid-50″> <div […]

Read More
Comments Off on User Stream

Stream View & Template

[app.py] … @app.route(‘/stream’) @app.route(‘/stream/’) def stream(username=None): template = ‘stream.html’ if username and username != current_user.username: user = models.User.select().where(models.User.username**username).get() stream = […]

Read More
Comments Off on Stream View & Template

Post Form & View

[app.py] from flask_login import (LoginManager, login_user, logout_user, login_required, current_user) … @app.before_request def before_request(): “””Connect to the database before each request.””” […]

Read More
Comments Off on Post Form & View

Posts of Authenticated Users

Links for Authenticated Users [layout.html] … <div class=”grid-33″> <!– Say Hi –> <h1>Hello {% if current_user.is_authenticated %}{{ current_user.username }}{% endif […]

Read More
Comments Off on Posts of Authenticated Users

Flash Messages

Python Code Flash is a Flask function. It uses the user’s session to display messages. Sessions in Flask are cryptographically […]

Read More
Comments Off on Flash Messages

JINJA2 Python Control

[app.py]: from flask import (Flask, render_template, request, redirect, make_response, url_for) import json from options import DEFAULTS app = Flask(__name__) @app.route(‘/’) […]

Read More
Comments Off on JINJA2 Python Control

Cookies with JSON

Cookies are for storing data between requests that our users submit through the form. Cookies are a great way for […]

Read More
Comments Off on Cookies with JSON

Cookies Simple

Simple Cookie Set & Get [simpleform.html]: <form action=”{{ url_for(‘setcookie’) }}” method=”POST”> <h3>Enter userID</h3> <input name=”fullname” type=”text” /> <input type=”submit” value=”Submit” […]

Read More
Comments Off on Cookies Simple

Forms

We have the following Build A Character app. app.py options.py [static] |__ [css] |__ [img] [templates] |__ builder.html |__ index.html |__ […]

Read More
Comments Off on Forms

CSS, Images & JavaScript

Using stylesheets, images and scripts will improve the appearance and experience of your app greatly. Place these files inside a folder […]

Read More
Comments Off on CSS, Images & JavaScript

Template Inheritance

Instead of repeating your HTML code for each template file you can use template inheritance, where templates can inherit from each […]

Read More
Comments Off on Template Inheritance

HTML Templates

App Inline HTML As you saw, Views can print variables. But it also can print HTML code on the web […]

Read More
Comments Off on HTML Templates

Query Strings & URLs

Query Strings Sending arguments and variables to URLs is important. Users can do that using Query Strings which are the […]

Read More
Comments Off on Query Strings & URLs