Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

comment feng-shui and some other minor fixes

  • Loading branch information...
commit b92964447bb6f14a8000497299d9ea51615c15a8 1 parent d24f1aa
@topsitemakers topsitemakers authored
View
52 app.py
@@ -1,29 +1,29 @@
-#------------------------------------------------------------------------------#
-# Imports
-#------------------------------------------------------------------------------#
+#----------------------------------------------------------------------------#
+# Imports.
+#----------------------------------------------------------------------------#
-from flask import * # do not use '*'; actually input the dependencies
+from flask import * # do not use '*'; actually input the dependencies.
from flask.ext.sqlalchemy import SQLAlchemy
import logging
from logging import Formatter, FileHandler
from forms import *
-#------------------------------------------------------------------------------#
-# App Config
-#------------------------------------------------------------------------------#
+#----------------------------------------------------------------------------#
+# App Config.
+#----------------------------------------------------------------------------#
app = Flask(__name__)
app.config.from_object('config')
#db = SQLAlchemy(app)
-# Automatically tear down SQLAlchemy
+# Automatically tear down SQLAlchemy.
'''
@app.teardown_request
def shutdown_session(exception=None):
db_session.remove()
'''
-# Login required decorator
+# Login required decorator.
'''
def login_required(test):
@wraps(test)
@@ -35,34 +35,34 @@ def wrap(*args, **kwargs):
return redirect(url_for('login'))
return wrap
'''
-#------------------------------------------------------------------------------#
-# Controllers
-#------------------------------------------------------------------------------#
+#----------------------------------------------------------------------------#
+# Controllers.
+#----------------------------------------------------------------------------#
-@app.route("/")
+@app.route('/')
def home():
- return render_template("pages/placeholder.home.html")
+ return render_template('pages/placeholder.home.html')
@app.route('/about')
def about():
return render_template('pages/placeholder.about.html')
-@app.route("/login")
+@app.route('/login')
def login():
form = LoginForm(request.form)
- return render_template("forms/login.html", form = form)
+ return render_template('forms/login.html', form = form)
-@app.route("/register")
+@app.route('/register')
def register():
form = RegisterForm(request.form)
- return render_template("forms/register.html", form = form)
+ return render_template('forms/register.html', form = form)
@app.route('/forgot')
def forgot():
form = ForgotForm(request.form)
return render_template('forms/forgot.html', form = form)
-# Error Handlers
+# Error handlers.
@app.errorhandler(500)
def internal_error(error):
@@ -82,17 +82,17 @@ def internal_error(error):
app.logger.addHandler(file_handler)
app.logger.info('errors')
-#------------------------------------------------------------------------------#
-# Launch
-#------------------------------------------------------------------------------#
+#----------------------------------------------------------------------------#
+# Launch.
+#----------------------------------------------------------------------------#
-# default port
+# Default port:
if __name__ == '__main__':
app.run()
-# or specify port
+# Or specify port manually:
'''
-if __name__ == "__main__":
- port = int(os.environ.get("PORT", 5000))
+if __name__ == '__main__':
+ port = int(os.environ.get('PORT', 5000))
app.run(host='0.0.0.0', port=port)
'''
View
10 config.py
@@ -1,13 +1,13 @@
import os
-# grabs the folder where the script runs
+# Grabs the folder where the script runs.
basedir = os.path.abspath(os.path.dirname(__file__))
-# enable debug mode
+# Enable debug mode.
DEBUG = True
-# secret key for session management
-SECRET_KEY = 'my precious'
+# Secret key for session management.
+SECRET_KEY = 'asdf'
-# connect to the database
+# Connect to the database
SQLALCHEMY_DATABASE_URI = 'sqlite:///' + os.path.join(basedir, 'database.db')
View
2  forms.py
@@ -1,7 +1,7 @@
from flask.ext.wtf import Form, TextField, PasswordField
from flask.ext.wtf import Required, EqualTo, validators, Length
-# set your classes here
+# Set your classes here.
class RegisterForm(Form):
name = TextField('Username', validators = [Required(), Length(min=6, max=25)])
View
4 models.py
@@ -11,7 +11,7 @@
Base = declarative_base()
Base.query = db_session.query_property()
-# set your classes here
+# Set your classes here.
'''
class User(Base):
@@ -27,5 +27,5 @@ def __init__(self, name=None, password=None):
self.password = password
'''
-# create tables
+# Create tables.
Base.metadata.create_all(bind=engine)
View
2  templates/forms/forgot.html
@@ -1,4 +1,4 @@
-{% extends "layouts/form.html" %}
+{% extends 'layouts/form.html' %}
{% block title %}Reset Password{% endblock %}
{% block content %}
<form method="post" class="form form-reset">
View
6 templates/forms/login.html
@@ -1,7 +1,7 @@
-{% extends "layouts/form.html" %}
-{% block title %} method="post"Login{% endblock %}
+{% extends 'layouts/form.html' %}
+{% block title %}Login{% endblock %}
{% block content %}
- <form method="post" action="" class="form">
+ <form method="post" class="form">
<h3 class="form-heading">Login <a href="{{ url_for('home') }}" title="Back to homepage"><i class="icon icon-home pull-right"></i></a></h3>
{{ form.name(class_ = 'form-control first-input', placeholder = form.name.label.text, required = true, autofocus = true) }}
{{ form.password(class_ = 'form-control last-input', placeholder = form.password.label.text, required = true) }}
View
2  templates/forms/register.html
@@ -1,5 +1,5 @@
{% extends 'layouts/form.html' %}
-{% block title %} method="post"Register{% endblock %}
+{% block title %}Register{% endblock %}
{% block content %}
<form method="post" class="form">
<h3 class="form-heading">Register <a href="{{ url_for('home') }}" title="Back to homepage"><i class="icon icon-home pull-right"></i></a></h3>
View
2  templates/pages/placeholder.home.html
@@ -1,5 +1,5 @@
{% extends 'layouts/main.html' %}
-{% block title %} - Home{% endblock %}
+{% block title %}Home{% endblock %}
{% block content %}
<div class="page-header">
Please sign in to comment.
Something went wrong with that request. Please try again.