Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 18e9758
Showing
53 changed files
with
17,171 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
env |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
web: python bootstrap.py $PORT --gevent |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
excssive | ||
======== | ||
|
||
Simplify your bloated CSS. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
""" | ||
Flask Documentation: http://flask.pocoo.org/docs/ | ||
Jinja2 Documentation: http://jinja.pocoo.org/2/documentation/ | ||
Werkzeug Documentation: http://werkzeug.pocoo.org/documentation/ | ||
This file creates your application. | ||
""" | ||
|
||
from flask import Flask | ||
from views import views | ||
import settings | ||
|
||
|
||
def create_app(): | ||
"""Create your application.""" | ||
app = Flask(__name__, static_folder='../static', | ||
template_folder='../templates') | ||
app.config.from_object(settings) | ||
app.register_blueprint(views) | ||
return app | ||
|
||
|
||
if __name__ == '__main__': | ||
app = create_app() | ||
app.run(debug=True) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
""" | ||
WTForms Documentation: http://wtforms.simplecodes.com/ | ||
Flask WTForms Patterns: http://flask.pocoo.org/docs/patterns/wtforms/ | ||
Flask-WTF Documentation: http://packages.python.org/Flask-WTF/ | ||
Forms for your application can be stored in this file. | ||
""" | ||
|
||
from flaskext.wtf import Form, SubmitField, TextField, Required, Email | ||
|
||
class ExampleForm(Form): | ||
"""Just a simple example form.""" | ||
name = TextField('Name', validators=[Required()]) | ||
email = TextField('Email', validators=[Email()]) | ||
location = TextField('Location') | ||
submit = SubmitField('Submit') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
""" | ||
You can store your app's configuration settings here. | ||
Generate good secret keys: http://flask.pocoo.org/docs/quickstart/#sessions | ||
>>> import os | ||
>>> os.urandom(24) | ||
'\xfd{H\xe5<\x95\xf9\xe3\x96.5\xd1\x01O<!\xd5\xa2\xa0\x9fR"\xa1\xa8' | ||
""" | ||
|
||
SECRET_KEY = "this_is_my_secret_key_that_I_should_change_with_os.urandom" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
""" | ||
Flask Blueprint Docs: http://flask.pocoo.org/docs/api/#flask.Blueprint | ||
This file is used for both the routing and logic of your | ||
application. | ||
""" | ||
|
||
from flask import Blueprint, render_template, request, redirect, url_for | ||
|
||
views = Blueprint('views', __name__, static_folder='../static', | ||
template_folder='../templates') | ||
|
||
|
||
@views.route('/') | ||
def home(): | ||
"""Render website's home page.""" | ||
return render_template('home.html') | ||
|
||
|
||
# The functions below should be applicable to all Flask apps. | ||
|
||
@views.route('/<file_name>.txt') | ||
def send_text_file(file_name): | ||
"""Send your static text file.""" | ||
file_dot_text = file_name + '.txt' | ||
return views.send_static_file(file_dot_text) | ||
|
||
|
||
@views.after_request | ||
def add_header(response): | ||
""" | ||
Add headers to both force latest IE rendering engine or Chrome Frame, | ||
and also to cache the rendered page for 10 minutes. | ||
""" | ||
response.headers['X-UA-Compatible'] = 'IE=Edge,chrome=1' | ||
response.headers['Cache-Control'] = 'public, max-age=600' | ||
return response | ||
|
||
|
||
@views.app_errorhandler(404) | ||
def page_not_found(error): | ||
"""Custom 404 page.""" | ||
return render_template('404.html'), 404 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
#!/usr/bin/env python | ||
|
||
""" | ||
Bootstrap and serve your application. If you're in a development environment, | ||
envoke the script with: | ||
$ python bootstrap.py | ||
You can also specify the port you want to use: | ||
$ python bootstrap.py 5555 | ||
You can easily test the production `tornado` server, too: | ||
$ python bootstrap.py --tornado | ||
Alternatively, your application can be run with the `gevent` Python library: | ||
$ python bootstrap.py --gevent | ||
""" | ||
|
||
import argparse | ||
from app import create_app | ||
|
||
|
||
def parse_arguments(): | ||
"""Parse any additional arguments that may be passed to `bootstrap.py`.""" | ||
parser = argparse.ArgumentParser() | ||
parser.add_argument('port', nargs='?', default=5000, type=int, | ||
help="An integer for the port you want to use.") | ||
parser.add_argument('--gevent', action='store_true', | ||
help="Run gevent's production server.") | ||
parser.add_argument('--tornado', action='store_true', | ||
help="Run gevent's production server.") | ||
args = parser.parse_args() | ||
return args | ||
|
||
|
||
def serve_app(environment): | ||
""" | ||
Serve your application. If `dev_environment` is true, then the | ||
application will be served using gevent's WSGIServer. | ||
""" | ||
app = create_app() | ||
# Use the $PORT variable on heroku's environment. | ||
port = environment.port | ||
if environment.gevent: | ||
from gevent.wsgi import WSGIServer | ||
http_server = WSGIServer(('', port), app) | ||
http_server.serve_forever() | ||
elif environment.tornado: | ||
from tornado.wsgi import WSGIContainer | ||
from tornado.httpserver import HTTPServer | ||
from tornado.ioloop import IOLoop | ||
http_server = HTTPServer(WSGIContainer(app)) | ||
http_server.listen(port) | ||
IOLoop.instance().start() | ||
else: | ||
app.run(debug=True, port=port) | ||
|
||
|
||
def main(): | ||
dev_environment = parse_arguments() | ||
serve_app(dev_environment) | ||
|
||
|
||
if __name__ == '__main__': | ||
main() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
# ---------------------- | ||
# Flask | ||
# ---------------------- | ||
flask | ||
|
||
|
||
# ---------------------- | ||
# Testing | ||
# ---------------------- | ||
mock | ||
|
||
|
||
# ---------------------- | ||
# Production Server | ||
# ---------------------- | ||
gevent |
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Oops, something went wrong.