Skip to content

Commit

Permalink
First commit
Browse files Browse the repository at this point in the history
  • Loading branch information
zachwill committed Oct 30, 2011
0 parents commit 18e9758
Show file tree
Hide file tree
Showing 53 changed files with 17,171 additions and 0 deletions.
1 change: 1 addition & 0 deletions .gitignore
@@ -0,0 +1 @@
env
1 change: 1 addition & 0 deletions Procfile
@@ -0,0 +1 @@
web: python bootstrap.py $PORT --gevent
4 changes: 4 additions & 0 deletions README.md
@@ -0,0 +1,4 @@
excssive
========

Simplify your bloated CSS.
25 changes: 25 additions & 0 deletions app/__init__.py
@@ -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)
16 changes: 16 additions & 0 deletions app/forms.py
@@ -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')
10 changes: 10 additions & 0 deletions app/settings.py
@@ -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"
43 changes: 43 additions & 0 deletions app/views.py
@@ -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
68 changes: 68 additions & 0 deletions bootstrap.py
@@ -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()
16 changes: 16 additions & 0 deletions requirements.txt
@@ -0,0 +1,16 @@
# ----------------------
# Flask
# ----------------------
flask


# ----------------------
# Testing
# ----------------------
mock


# ----------------------
# Production Server
# ----------------------
gevent
Binary file added static/apple-touch-icon-114x114-precomposed.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added static/apple-touch-icon-57x57-precomposed.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added static/apple-touch-icon-72x72-precomposed.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added static/apple-touch-icon-precomposed.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added static/apple-touch-icon.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 18e9758

Please sign in to comment.