skip to navigation
skip to content

Not Logged In

flasker 0.1.10


Latest Version: 0.1.45


**What Flasker is**
Flask_ webapp template with optional Celery_ backend.

**What Flasker isn't**
An easy way to learn Flask, SQLAlchemy and Celery. Flasker works behind the scene to tie these three tools together so that it 'works' but at the same time exposes the bare webapp, celery worker and database objects. This integration is meant to be as transparent as possible, to let you configure these individually according to your project needs.

Feature highlights

* `Database backend ready to use`_
* `User authentication using Google OAuth`_
* `Running and scheduling jobs with Celery`_
* Includes jQuery_ and Bootstrap_ CSS and JS libraries


* **Installation**::

$ pip install flasker

* **To create a new project**::

$ flasker

You will be prompted...
This will run the server (using Werkzeug) on port 5050. Also:

* Append the ``-d`` flag to run the server in debug mode (enables autoreload and in-browser debugger)
* A list of available commands is available by running ``python``


Database backend ready to use

The app uses SQLAlchemy_ and offers several helpers to create persistent models. By default, the database backend uses SQLite_ but this can be changed by editing ``APP_DB_URL`` in the ``app/core/`` file. If MySQL_ is used, full write concurrency is supported (even with the Celery_ worker).

Here are a few of the helpers available on the default ``Base`` model class:

* Jsonifiable
* Loggable
* Cacheable

And more:

* api_response
* Dict

User authentication using Google OAuth

* **Setup**

Inside ``app/core/``, set ``USE_OAUTH = True`` and fill in the ``GOOGLE_CLIENT_ID`` and ``GOOGLE_CLIENT_SECRET``. If you don't know what these are, you can read about them and create your own in the `Google API Console`_.

* **Usage**

To restrict some pages to logged-in users, add the `login_required` to the corresponding view. E.g::

def some_protected_page():
return render_templage('template.html')

At first, there are no authorized users, in order to authorize someone to log in, run the following command and enter the email you want to authorize when prompted::

$ python add_user

You can view the list of authorized users at any time by running::

$ python view_users

Running and scheduling jobs with Celery

* **Setup**

First, if you don't yet have Redis, here is how to install it::

$ curl -O
$ tar xvzf redis-stable.tar.gz
$ cd redis-stable
$ make
$ make test
$ sudo cp redis-server /usr/local/bin/
$ sudo cp redis-cli /usr/local/bin/

Finally, inside ``app/core/``, set ``USE_CELERY = True``.

* **Usage**

Run the following command to start the worker::

$ python run_worker

To learn how to create tasks and schedule them, please refer to the official Celery_ documentation.

* **Optional extra steps**

* Daemonizing redis on a mac

Create a plist file::

$ sudo vim /Library/LaunchDaemons/io.redis.redis-server.plist

Copy the following contents::

<plist version="1.0">

Running the server on Apache

Create a file called `run.wsgi` in the main directory with the following contents::

# Virtualenv activation
from os.path import abspath, dirname, join
activate_this = abspath(join(dirname(__file__), 'venv/bin/'))
execfile(activate_this, dict(__file__=activate_this))

# Since the application isn't on the path
import sys
sys.path.insert(0, abspath(join(dirname(__file__)))

# App factory
from app import make_app
application = make_app()

Then add a virtualhost in your Apache virtual host configuration file (often found at `/etc/apache2/extra/httpd-vhosts.conf`) with the following configuration::

<virtualhost *:80="">
ServerName [server_name]
WSGIDaemonProcess [process_name] user=[process_user] threads=5
WSGIScriptAlias / [path_to_wsgi_file]
<directory [path_to_root_directory]="">
WSGIProcessGroup [process_name]
WSGIApplicationGroup %{GLOBAL}
Order deny,allow
Allow from all
ErrorLog "[path_to_error_log]"
CustomLog "[path_to_access_log]" combined



.. _Bootstrap:
.. _Flask:
.. _Jinja:
.. _Celery:
.. _Datatables:
.. _SQLAlchemy:
.. _MySQL:
.. _`Google OAuth 2.0`:
.. _`Google API console`:
.. _jQuery:
.. _`jQuery UI`:  
File Type Py Version Uploaded on Size
flasker-0.1.10.tar.gz (md5) Source 2013-01-25 21KB
  • Downloads (All Versions):
  • 51 downloads in the last day
  • 842 downloads in the last week
  • 2742 downloads in the last month