changeset 69:dcf870775c26

Add compability with flask 0.8 In flask version 0.10 (current stable version) the behaviour changed. With this version it is possible to specify the server and port via the config variable SERVER_NAME. To allow this behaviour also with flask 0.8 which is the version shipped with Debian Wheezy this commit extracts the host and port from the SERVER_NAME config variable.
author Björn Ricks <bjoern.ricks@intevation.de>
date Mon, 05 Jan 2015 12:37:56 +0100
parents 4645e50539ff
children 5607a1171223
files main.py
diffstat 1 files changed, 10 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/main.py	Tue Dec 02 17:06:33 2014 +0100
+++ b/main.py	Mon Jan 05 12:37:56 2015 +0100
@@ -1,4 +1,13 @@
 # -*- coding: utf-8 -*-
 if __name__ == "__main__":
     from odfcast import app
-    app.run()
+
+    server_name = app.config['SERVER_NAME']
+    if server_name and ':' in server_name:
+        host, port = server_name.rsplit(':', 1)
+        port = int(port)
+    else:
+        port = 5000
+        host = "127.0.0.1"
+
+    app.run(host=host, port=port)
This site is hosted by Intevation GmbH (Datenschutzerklärung und Impressum | Privacy Policy and Imprint)