flask-appengine-template

Boilerplate project template for running Flask on Google App Engine

  • Owner: kamalgill/flask-appengine-template
  • Platform:
  • License::
  • Category::
  • Topic:
  • Like:
    0
      Compare:

Github stars Tracking Chart

Flask on App Engine Project Template (Deprecated)

IMPORTANT: This project is deprecated (primarily due to Python 2 end-of-life as of 1 Jan 2020)
and has been supplanted by the following, which supports Flask in Python 3
on Google App Engine's second-generation runtimes...

https://github.com/kamalgill/cloud-starterkit-flask-appengine

Boilerplate project template for running a Flask-based application on
Google App Engine's Standard Python 2.7 Runtime

Similar boilerplate projects are listed below:

App Engine Flexible Environment

This project does not currently support deployments on the App Engine Flexible environment,
although it could potentially work on App Engine Flexible with some modifications.

See the official Quickstart for Python in the App Engine Flexible Environment
if you are looking to deploy Python 2.7 and 3.x applications on App Engine

About Flask

Flask is a BSD-licensed microframework for Python based on
Werkzeug, Jinja2 and good intentions.

See http://flask.pocoo.org for more info.

Setup/Configuration

  1. Download this repository via
    git clone https://github.com/kamalgill/flask-appengine-template.git
    or download the tarball at
    http://github.com/kamalgill/flask-appengine-template/tarball/master
  2. Copy the src/ folder to your application's root folder
  3. Set the application id in src/app.yaml
  4. Configure datastore models at src/application/models.py
  5. Configure application views at src/application/views/
  6. Configure URL routes at src/application/urls.py
  7. Configure forms at src/application/forms.py
  8. Add the secret keys for CSRF protection by running the generate_keys.py
    script at src/application/generate_keys.py, which will generate the
    secret keys module at src/application/secret_keys.py

Note: Copy the .gitignore file from the tarball folder's root to your git
repository root to keep the secret_keys module out of version control.

Or, add the following to your .(git, hg, bzr)ignore file

Install python dependencies

The local dev environment requires installation of Jinja2, PIL, and simplejson,
which can be installed via:

Front-end Customization

  1. Customize the main HTML template at
    src/application/templates/base.html
  2. Customize CSS styles at src/application/static/css/main.css
  3. Add custom JavaScript code at src/application/static/js/main.js
  4. Customize favicon at src/application/static/img/favicon.ico
  5. Customize 404 page at src/application/templates/404.html

Previewing the Application

To preview the application using App Engine's development server,
use dev_appserver.py

Assuming the latest App Engine SDK is installed, the test environment is
available at http://localhost:8080

Admin Console

The admin console is viewable at http://localhost:8000 (note distinct port from dev app server)

Flask-Cache

The handy Flask-Cache extension is included, pre-configured for App Engine's Memcache API.
Use the "Flush Cache" button at http://localhost:8000/memcache to clear the cache.

Testing

Place all your tests in src/tests directory. Test runner is placed in src directory. To run your tests simply go to src directory and do:

Path to your local google app engine installation must be provided as first argument to the script. If the path is long and you don't like to type it each time you run the tests you can also hardcode it in apptest.py, just edit the variable SDK_PATH and set it to your google app engine folder.

Before running tests set evironment variable FLASK_CONF to the value TEST.

In Linux this is done by:

In Powershell:

Remember to restart Powershell. Change of environment variable will take place after restarting Powershell.

You can specify your testing configuration (e.g. separate database for tests results) in src/application/settings.py.

To switch back to development configuration just set FLASK_CONF to DEV.

Deploying the Application

To deploy the application to App Engine, use appcfg.py update

The application should be visible at http://{YOURAPPID}.appspot.com

Folder structure

The App Engine app's root folder is located at src/.

The application code is located at src/application.

Licenses

See licenses/ folder

Package Versions

  • Blinker: 1.4
  • Bootstrap: 3.0.0
  • Click: 6.7
  • Flask: 0.12.2
  • Flask-Cache 0.13.1
  • Flask-DebugToolbar: 0.10.1
  • Flask-WTF: 0.14.2
  • FontAwesome: 3.0
  • itsdangerous: 0.24
  • Jinja2: 2.6 (included in GAE)
  • jQuery: 3.2.1 (set in base.html)
  • Modernizr: 2.6.2
  • Werkzeug: 0.12.2
  • WTForms: 2.1

Credits

Project template layout was heavily inspired by Francisco Souza's
gaeseries Flask project

Incorporates Flask-DebugToolbar by Matt Good et. al.
and Flask-Cache by Thadeus Burgess

Layout, form, table, and button styles provided by Bootstrap

Font Awesome by Dave Gandy

HTML5 detection provided by Modernizr 2 (configured with all features)

Main metrics

Overview
Name With Ownerkamalgill/flask-appengine-template
Primary LanguagePython
Program languageMakefile (Language Count: 5)
Platform
License:
所有者活动
Created At2010-09-19 17:42:15
Pushed At2019-12-24 20:16:02
Last Commit At2019-12-24 12:15:56
Release Count14
Last Release Name0.6.0 (Posted on )
First Release Name0.1 (Posted on )
用户参与
Stargazers Count1.1k
Watchers Count66
Fork Count205
Commits Count246
Has Issues Enabled
Issues Count54
Issue Open Count4
Pull Requests Count26
Pull Requests Open Count0
Pull Requests Close Count4
项目设置
Has Wiki Enabled
Is Archived
Is Fork
Is Locked
Is Mirror
Is Private