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 664b54e
Showing
152 changed files
with
43,652 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 | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -0,0 +1,2 @@ | |||
index.yaml | |||
*.pyc |
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 | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -0,0 +1,30 @@ | |||
gae-flask-html5 | |||
=============== | |||
|
|||
# What is this? | |||
|
|||
Just a simple Flask skeleton for Google App Engine, but made with all the | |||
baked-in-goodness of html5 boilerplate. | |||
|
|||
I'm planning on using this for my projects going forward (really like the | |||
speed of Flask compared to Django-Nonrel on GAE), so I thought someone | |||
else might find it useful, too. | |||
|
|||
Also, I included a style.less file since I primarily only use the Less app | |||
(http://incident57.com/less/) when writing stylesheets nowadays. | |||
|
|||
|
|||
Setup | |||
------ | |||
|
|||
git clone https://github.com/zachwill/gae-flask-html5.git <your_app_name> | |||
|
|||
Run | |||
------ | |||
|
|||
dev_appserver.py . | |||
|
|||
Deploy | |||
------ | |||
|
|||
appcfg.py update . |
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 | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -0,0 +1,37 @@ | |||
# | |||
# Flask Documentation: http://flask.pocoo.org/docs/ | |||
# Jinja2 Documentation: http://jinja.pocoo.org/2/documentation/ | |||
# Werkzeug Documentation: http://werkzeug.pocoo.org/documentation/ | |||
# The Python Datastore API: http://code.google.com/appengine/docs/python/datastore/ | |||
# | |||
|
|||
from flask import Flask, url_for, render_template, request, redirect | |||
from models import Todo | |||
|
|||
app = Flask(__name__) | |||
|
|||
|
|||
@app.route('/') | |||
def index(): | |||
"""Render our website's index page.""" | |||
return render_template('index.html') | |||
|
|||
|
|||
@app.route('/todo/') | |||
def todo_list(): | |||
"""Simple todo page.""" | |||
return render_template('todo.html', todos=Todo.all().order('-created_at')) | |||
|
|||
|
|||
@app.route('/todo/add', methods=["POST"]) | |||
def add_todo(): | |||
"""Add a todo.""" | |||
todo = Todo(text=request.form['text']) | |||
todo.save() | |||
return redirect(url_for('todo_list')) | |||
|
|||
|
|||
@app.errorhandler(404) | |||
def page_not_found(e): | |||
"""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 | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -0,0 +1,35 @@ | |||
application: your-app-name-here | |||
version: 1 | |||
runtime: python | |||
api_version: 1 | |||
|
|||
|
|||
builtins: | |||
- appstats: on | |||
- remote_api: on | |||
- datastore_admin: on | |||
|
|||
|
|||
handlers: | |||
|
|||
- url: /favicon.ico | |||
static_files: static/img/favicon.ico | |||
upload: static/img/favicon.ico | |||
|
|||
- url: /apple-touch-icon.png | |||
static_files: static/img/apple-touch-icon.png | |||
upload: static/img/apple-touch-icon.png | |||
|
|||
- url: /robots.txt | |||
static_files: static/robots.txt | |||
upload: static/robots.txt | |||
|
|||
- url: /humans.txt | |||
static_files: static/humans.txt | |||
upload: static/humans.txt | |||
|
|||
- url: /static | |||
static_dir: static | |||
|
|||
- url: /.* | |||
script: bootstrap.py |
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 | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -0,0 +1,13 @@ | |||
import sys | |||
import os | |||
|
|||
# Let's keep flask, jinja2, and werkzeug in a separate libs folder. | |||
# NOTE: You can add other libraries here, too -- and still | |||
# import them as normal. | |||
|
|||
ROOT_DIR = os.path.dirname(os.path.abspath(__file__)) | |||
sys.path.insert(0, os.path.join(ROOT_DIR, 'libs')) | |||
|
|||
from wsgiref.handlers import CGIHandler | |||
from app import app | |||
CGIHandler().run(app) |
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 | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -0,0 +1,34 @@ | |||
# -*- coding: utf-8 -*- | |||
""" | |||
flask | |||
~~~~~ | |||
A microframework based on Werkzeug. It's extensively documented | |||
and follows best practice patterns. | |||
:copyright: (c) 2010 by Armin Ronacher. | |||
:license: BSD, see LICENSE for more details. | |||
""" | |||
|
|||
# utilities we import from Werkzeug and Jinja2 that are unused | |||
# in the module but are exported as public interface. | |||
from werkzeug import abort, redirect | |||
from jinja2 import Markup, escape | |||
|
|||
from .app import Flask, Request, Response | |||
from .config import Config | |||
from .helpers import url_for, jsonify, json_available, flash, \ | |||
send_file, send_from_directory, get_flashed_messages, \ | |||
get_template_attribute, make_response | |||
from .globals import current_app, g, request, session, _request_ctx_stack | |||
from .module import Module | |||
from .templating import render_template, render_template_string | |||
from .session import Session | |||
|
|||
# the signals | |||
from .signals import signals_available, template_rendered, request_started, \ | |||
request_finished, got_request_exception | |||
|
|||
# only import json if it's available | |||
if json_available: | |||
from .helpers import json |
Oops, something went wrong.