summaryrefslogtreecommitdiff
path: root/kosten/app/__init__.py
blob: 7079d8c92f79491254a92f43dae99402328b308f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
from flask import Flask
import simplejson

# create app
app = Flask('kosten', instance_relative_config = True)

# simplejson knows how to handle Decimal
app.json_encoder = simplejson.JSONEncoder

# force autoescape in all files
app.jinja_env.autoescape = True

app.jinja_env.lstrip_blocks = True
app.jinja_env.trim_blocks = True

# load config
app.config.from_object('settings')
app.config.from_pyfile('settings.py', silent = True)

from .model import db
from .login import login_manager
from . import views

# commands
@app.cli.command()
def create():
    db.create_all()

@app.cli.command()
def drop():
    db.drop_all()

@app.cli.command()
def compile():
    """Compiles all templates."""
    app.jinja_env.compile_templates('comp', zip = None)