Sending Data with the Requests

Sending Data with a GET Request In a GET request, additional data related to your requested resource is passed as […]

Read More
Comments Off on Sending Data with the Requests

Response Format

200 level codes are success messages, particularly 200 code which is the message OK. 301 Page moved. 404 is Not […]

Read More
Comments Off on Response Format

Request Format

Request-Line The first line GET /xml HTTP/1.1 is called the request line. GET | POST GET is used when you […]

Read More
Comments Off on Request Format

What is HTTP?

HTTP Hyper Text Transfer Protocol: A set of rules that govern how 2 devices should communicate with each other over […]

Read More
Comments Off on What is HTTP?

404.html

{% extends “layout.html” %} {% block content %} <h1>404</h1> <p>Wow, sorry, that page doesn’t exist.</p> <p><a href=”{{ url_for(‘index’) }}”>Try again</a></p> […]

Read More
Comments Off on 404.html

user_stream.html

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

Read More
Comments Off on user_stream.html

stream.html

{% extends “layout.html” %} {% block content %} {% for post in stream %}     <article>         <h2>             <a […]

Read More
Comments Off on stream.html

post.html

{% extends “layout.html” %} {% from ‘macros.html’ import render_field %} {% block content %} <form method=”POST” action=””>     {{ form.hidden_tag() […]

Read More
Comments Off on post.html

macros.html

{% macro render_field(field) %}     <div class=”field”>         {% if field.errors %}             {% for error in field.errors %}                 […]

Read More
Comments Off on macros.html

login.html

{% extends “layout.html” %} {% from ‘macros.html’ import render_field %} {% block content %} <form method=”POST” action=”” class=”form”>     {{ […]

Read More
Comments Off on login.html

register.html

{% extends “layout.html” %} {% from ‘macros.html’ import render_field %} {% block content %} <form method=”POST” action=”” class=”form”>     {{ […]

Read More
Comments Off on register.html

layout.html

<!DOCTYPE html> <html class=”no-js”>     <head>         <meta charset=”utf-8″>         <meta http-equiv=”X-UA-Compatible” content=”IE=edge,chrome=1″>         <title>{% block title %}TwoCans{% endblock %}</title> […]

Read More
Comments Off on layout.html

app.py

from flask import (Flask, g, render_template, flash, redirect, url_for, abort) from flask_bcrypt import check_password_hash from flask_login import (LoginManager, login_user, logout_user, […]

Read More
Comments Off on app.py

form.py

from flask_wtf import Form from wtforms import StringField, PasswordField, TextAreaField from wtforms.validators import (DataRequired, Regexp, ValidationError, Email, Length, EqualTo) from […]

Read More
Comments Off on form.py

models.py

import datetime from flask_bcrypt import generate_password_hash from flask_login import UserMixin from peewee import * DATABASE = SqliteDatabase(‘social.db’) class User(UserMixin, Model): […]

Read More
Comments Off on models.py

Handling 404

We can control 404 errors and bad requests using the abort() function provided by flask. What it does is that […]

Read More
Comments Off on Handling 404

Viewing Followed Posts

[models.py] class User(UserMixin, Model): …. def get_stream(self): return Post.select().where( (Post.user << self.following()) | (Post.user == self) ) def following(self): …. […]

Read More
Comments Off on Viewing Followed Posts

Showing Followers

[user_stream.html] … <div class=”grid-25″> <h5>Followers</h5> <p>{{ user.followers().count() }}</p> </div> <div class=”grid-25″> <h5>Following</h5> <p>{{ user.following().count() }}</p> </div> … <div class=”grid-25″> {% […]

Read More
Comments Off on Showing Followers

WCAG 2.0 Checklist

Read More

Relationship Model & Views

Relationship Model [models.py] … class User(UserMixin, Model): … def following(self): “””Users that current user follows.””” return User.select().join( Relationship, on=Relationship.to_user ).where( […]

Read More
Comments Off on Relationship Model & Views