Mercurial > odfcast
annotate main.py @ 23:709edf15f90e
Add a index view to display links to the three functions
author | Björn Ricks <bjoern.ricks@intevation.de> |
---|---|
date | Mon, 29 Sep 2014 16:07:49 +0200 |
parents | c289263e1b24 |
children | 9d65de2ebe22 |
rev | line source |
---|---|
0
4a34f72f036b
Add initial conversion service
Björn Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
1 # -*- coding: utf-8 -*- |
14
53c7a99cabae
Set log level to debug if config["DEBUG"] is set
Björn Ricks <bjoern.ricks@intevation.de>
parents:
6
diff
changeset
|
2 import logging |
0
4a34f72f036b
Add initial conversion service
Björn Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
3 |
4a34f72f036b
Add initial conversion service
Björn Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
4 from flask import Flask |
4a34f72f036b
Add initial conversion service
Björn Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
5 |
4a34f72f036b
Add initial conversion service
Björn Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
6 app = Flask(__name__) |
4a34f72f036b
Add initial conversion service
Björn Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
7 app.config.from_object('odfcast.settings') |
4a34f72f036b
Add initial conversion service
Björn Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
8 app.config.from_envvar('ODFCAST_SETTINGS', silent=True) |
4a34f72f036b
Add initial conversion service
Björn Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
9 |
14
53c7a99cabae
Set log level to debug if config["DEBUG"] is set
Björn Ricks <bjoern.ricks@intevation.de>
parents:
6
diff
changeset
|
10 if app.config["DEBUG"]: |
53c7a99cabae
Set log level to debug if config["DEBUG"] is set
Björn Ricks <bjoern.ricks@intevation.de>
parents:
6
diff
changeset
|
11 logging.basicConfig(level=logging.DEBUG) |
53c7a99cabae
Set log level to debug if config["DEBUG"] is set
Björn Ricks <bjoern.ricks@intevation.de>
parents:
6
diff
changeset
|
12 |
23
709edf15f90e
Add a index view to display links to the three functions
Björn Ricks <bjoern.ricks@intevation.de>
parents:
20
diff
changeset
|
13 from odfcast.convert import ConvertView, TemplateConvertView, MergeView, \ |
709edf15f90e
Add a index view to display links to the three functions
Björn Ricks <bjoern.ricks@intevation.de>
parents:
20
diff
changeset
|
14 TemplateView |
14
53c7a99cabae
Set log level to debug if config["DEBUG"] is set
Björn Ricks <bjoern.ricks@intevation.de>
parents:
6
diff
changeset
|
15 |
0
4a34f72f036b
Add initial conversion service
Björn Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
16 |
4a34f72f036b
Add initial conversion service
Björn Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
17 app.add_url_rule("/convert/", |
4a34f72f036b
Add initial conversion service
Björn Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
18 view_func=ConvertView.as_view( |
4a34f72f036b
Add initial conversion service
Björn Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
19 "convert", |
4a34f72f036b
Add initial conversion service
Björn Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
20 app.config["PY3O_UNO_DRIVER"], |
4a34f72f036b
Add initial conversion service
Björn Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
21 app.config["PY3O_UNO_SERVER_HOSTNAME"], |
4a34f72f036b
Add initial conversion service
Björn Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
22 app.config["PY3O_UNO_SERVER_PORT"], |
4a34f72f036b
Add initial conversion service
Björn Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
23 )) |
6
7f546e8a6e7a
Add url mapping for TemplateConvertView
Björn Ricks <bjoern.ricks@intevation.de>
parents:
0
diff
changeset
|
24 app.add_url_rule("/template/", |
7f546e8a6e7a
Add url mapping for TemplateConvertView
Björn Ricks <bjoern.ricks@intevation.de>
parents:
0
diff
changeset
|
25 view_func=TemplateConvertView.as_view( |
7f546e8a6e7a
Add url mapping for TemplateConvertView
Björn Ricks <bjoern.ricks@intevation.de>
parents:
0
diff
changeset
|
26 "template", |
7f546e8a6e7a
Add url mapping for TemplateConvertView
Björn Ricks <bjoern.ricks@intevation.de>
parents:
0
diff
changeset
|
27 app.config["PY3O_UNO_DRIVER"], |
7f546e8a6e7a
Add url mapping for TemplateConvertView
Björn Ricks <bjoern.ricks@intevation.de>
parents:
0
diff
changeset
|
28 app.config["PY3O_UNO_SERVER_HOSTNAME"], |
7f546e8a6e7a
Add url mapping for TemplateConvertView
Björn Ricks <bjoern.ricks@intevation.de>
parents:
0
diff
changeset
|
29 app.config["PY3O_UNO_SERVER_PORT"], |
7f546e8a6e7a
Add url mapping for TemplateConvertView
Björn Ricks <bjoern.ricks@intevation.de>
parents:
0
diff
changeset
|
30 )) |
20
c289263e1b24
Add url rule for new MergeView
Björn Ricks <bjoern.ricks@intevation.de>
parents:
14
diff
changeset
|
31 app.add_url_rule("/merge/", |
c289263e1b24
Add url rule for new MergeView
Björn Ricks <bjoern.ricks@intevation.de>
parents:
14
diff
changeset
|
32 view_func=MergeView.as_view("merge"), |
c289263e1b24
Add url rule for new MergeView
Björn Ricks <bjoern.ricks@intevation.de>
parents:
14
diff
changeset
|
33 ) |
23
709edf15f90e
Add a index view to display links to the three functions
Björn Ricks <bjoern.ricks@intevation.de>
parents:
20
diff
changeset
|
34 app.add_url_rule("/", |
709edf15f90e
Add a index view to display links to the three functions
Björn Ricks <bjoern.ricks@intevation.de>
parents:
20
diff
changeset
|
35 view_func=TemplateView.as_view("index", "index.html"), |
709edf15f90e
Add a index view to display links to the three functions
Björn Ricks <bjoern.ricks@intevation.de>
parents:
20
diff
changeset
|
36 ) |
709edf15f90e
Add a index view to display links to the three functions
Björn Ricks <bjoern.ricks@intevation.de>
parents:
20
diff
changeset
|
37 |
0
4a34f72f036b
Add initial conversion service
Björn Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
38 |
4a34f72f036b
Add initial conversion service
Björn Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
39 if __name__ == "__main__": |
4a34f72f036b
Add initial conversion service
Björn Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
40 app.run() |