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

Diary Functions

[diary.py] #!/user/bin/env python3 import datetime import sys import os from collections import OrderedDict from peewee import * db = SqliteDatabase(‘diary.db’) […]

Read More
Comments Off on Diary Functions

Creating a Diary

[diary.py] #!/user/bin/env python3 from collections import OrderedDict import datetime from peewee import * db = SqliteDatabase(‘diary.db’) class Entry(Model): content = […]

Read More
Comments Off on Creating a Diary

C.R.U.D.

Create, Read, Update, Delete .select()  Displays records .create    Creates a new record .save()    Updates an existing record in the […]

Read More
Comments Off on C.R.U.D.

ORM & Modeling

ORMs Once upon a time, if you needed to interact with a database, you had to write SQL. But now […]

Read More
Comments Off on ORM & Modeling

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

HTML5 (Early Course)

Read More