Flask-GAE
Flask-GAE copied to clipboard
This is my Flask Google App Engine template.
#Flask on Google App Engine Template

______ __ ______ ______ __ __
/\ ___\ /\ \ /\ __ \ /\ ___\ /\ \/ /
\ \ __\ \ \ \____ \ \ __ \ \ \___ \ \ \ _"-.
\ \_\ \ \_____\ \ \_\ \_\ \/\_____\ \ \_\ \_\
\/_/ \/_____/ \/_/\/_/ \/_____/ \/_/\/_/
This project is my GAE project template.
And the example application uses History to link pages, so that all hyperlinks are ajax.
##Frameworks
- Flask 0.10.1
- Jinja 2.7.1
- Werkzeug 0.9.3
- Bootstrap 2.3.2
- jQuery 2.1.0
- Google App Engine Launcher 1.8.9
##How to use?
$ git clone --recursive git://github.com/kelp404/Flask-GAE.git
./
├─ application # Web application code
├─ flask # Flask framework
├─ jinja2 # Jinja framework
├─ tests # Unit tests
├─ werkzeug # Werkzeug framework
├─ app.yaml # GAE app config
├─ backends.yaml # GAE backends config
├─ cron_jobs.py # Cron jobs code
├─ cron.yaml # GAE Cron jobs config
├─ itsdangerous.py
└─ index.yaml # GAE datastore indexes config
./application/
├─ data_models # Datastore data model
├─ handlers # Web handlers (MVC's controller)
├─ models # Other models
├─ services # All business logic here (MVC's model)
├─ static
│ ├─ coffeescript # CoffeeScript
│ ├─ css
│ ├─ font
│ ├─ icon
│ ├─ img
│ ├─ javascript
│ ├─ binding.py # JavaScript, CSS binder
│ └─ robots.txt
├─ templates # Jinja templates (MVC's view)
├─ utilities # Web application's shared utilities(helpers)
├─ __init__.py
├─ config.py # Application config
└─ routes.py # Web application's routers
##Example application
Board: https://flask-gae-kelp.appspot.com/posts
Chat: https://flask-gae-kelp.appspot.com/chat
##Deploy with appcfg.py
You should create a GAE account.
https://appengine.google.com
###update app.yaml
application: flask-gae-kelp
'flask-gae-kelp' should replace to your Application Identifier.
###deploy project deploy
# Flask-GAE is the folder name of the project
$ appcfg.py update Flask-GAE/
deploy backends
$ appcfg.py backends Flask-GAE/ update
###deleting unused indexes
$ appcfg.py vacuum_indexes Flask-GAE/
# https://developers.google.com/appengine/docs/python/tools/uploadinganapp?hl=en#Deleting_Unused_Indexes
##Development
# install node modules
$ npm install
# run the local server and the file watcher to compile CoffeeScript
$ grunt dev
###Closure Compiler You could download compiler form Google Code.
[File Watchers][File Watchers]:
| Watcher Settings | value |
|---|---|
| Program | /Users/Kelp/tool/closure-compiler/compiler.jar |
| Arguments | --compilation_level SIMPLE_OPTIMIZATIONS --js $FileName$ |
| Output paths | $FileNameWithoutExtension$.min.js (Create output file from stdout) |
##Unittest Before test, you should run GAE local server, and clear datastore, text search, and update url in function 'setUp()'.
class TestFunctions(unittest.TestCase):
def setUp(self):
self.url = 'http://localhost:8081'
self.email = '[email protected]'
self.cookies = { 'dev_appserver_login': "[email protected]:True:111325016121394242422" }
clear datastore & text search:
--clear_datastore=yes --clear_search_indexes=yes
$ cd Flask-GAE
$ python tests
Python unit test reference: http://docs.python.org/2/library/unittest.html
##References