Mercurial > kraina_muminkow
annotate frontend/mfrontend/__init__.py @ 11:69ecfe51d585
Dodałem prosty prototyp API
author | Michał Rudowicz <michal.rudowicz@fl9.eu> |
---|---|
date | Mon, 07 Mar 2011 11:04:11 +0100 |
parents | 9a0a9fa7f91d |
children |
rev | line source |
---|---|
1 | 1 #!/usr/bin/python |
2 # -*- coding: utf-8 -*- | |
3 | |
4 import flask | |
2 | 5 from ConfigParser import SafeConfigParser, NoSectionError |
1 | 6 from mfrontend.views.frontend import frontend |
9
9a0a9fa7f91d
Dodałem prototyp listy zadań w systemie
Michał Rudowicz <michal.rudowicz@fl9.eu>
parents:
2
diff
changeset
|
7 from mfrontend.views.jobcontrol import jobcontrol |
11
69ecfe51d585
Dodałem prosty prototyp API
Michał Rudowicz <michal.rudowicz@fl9.eu>
parents:
9
diff
changeset
|
8 from mfrontend.views.api import api |
1 | 9 from mfrontend import db, utils |
10 | |
11 | |
12 #-- konfiguracja | |
2 | 13 config = SafeConfigParser() |
1 | 14 while True: |
15 try: | |
2 | 16 config.read('config.ini') |
1 | 17 DATABASE = config.get('Basic', 'Database') |
18 DEBUG = config.getboolean('Basic', 'Debug') | |
19 SECRET_KEY = config.get('Basic', 'Secret_Key') | |
20 break | |
2 | 21 except NoSectionError: |
1 | 22 utils.default_ini() |
23 #-- koniec konfiguracji | |
24 | |
25 app = flask.Flask(__name__) | |
26 app.register_module(frontend) | |
9
9a0a9fa7f91d
Dodałem prototyp listy zadań w systemie
Michał Rudowicz <michal.rudowicz@fl9.eu>
parents:
2
diff
changeset
|
27 app.register_module(jobcontrol, url_prefix="/jobs") |
11
69ecfe51d585
Dodałem prosty prototyp API
Michał Rudowicz <michal.rudowicz@fl9.eu>
parents:
9
diff
changeset
|
28 app.register_module(api, url_prefix="/api") |
1 | 29 app.config.from_object(__name__) |
30 app.config.from_envvar('MFRONTEND_SETTINGS', silent=True) | |
31 | |
32 @app.before_request | |
33 def before_request(): | |
34 """Funkcja wywoływana zawsze przed wykonaniem żądania""" | |
35 db.connect_db() | |
36 | |
37 @app.after_request | |
38 def after_request(response): | |
39 db.disconnect_db() | |
40 return response |