Browse Source

allows to configure listeting port and addr fixes #8

Jocelyn Delande 10 years ago
parent
commit
a620f59770
2 changed files with 10 additions and 1 deletions
  1. 7 0
      README.md
  2. 3 1
      backend.py

+ 7 - 0
README.md

@@ -26,6 +26,13 @@ To run in debug mode (auto-reload)
 Bottle will reload on source change, but not on template change if you're using
 Bottle will reload on source change, but not on template change if you're using
 an old version of bottle.
 an old version of bottle.
 
 
+You can specify listening port and address by setting `BIND_PORT` and
+`BIND_ADDR` env vars, ex:
+
+    BIND_ADDR='0.0.0.0' BIND_PORT=8081 ./backend.py
+
+Default is to listen on `127.0.0.0`, port `8080`.
+
 Create the DataBase
 Create the DataBase
 ===================
 ===================
 
 

+ 3 - 1
backend.py

@@ -353,6 +353,8 @@ def build_geojson():
 
 
 
 
 DEBUG = bool(os.environ.get('DEBUG', False))
 DEBUG = bool(os.environ.get('DEBUG', False))
+LISTEN_ADDR= os.environ.get('BIND_ADDR', 'localhost')
+LISTEN_PORT= int(os.environ.get('BIND_PORT', 8080))
 
 
 if __name__ == '__main__':
 if __name__ == '__main__':
     if len(sys.argv) > 1:
     if len(sys.argv) > 1:
@@ -361,5 +363,5 @@ if __name__ == '__main__':
         if sys.argv[1] == 'buildgeojson':
         if sys.argv[1] == 'buildgeojson':
             build_geojson()
             build_geojson()
     else:
     else:
-        run(host='localhost', port=8080, reloader=DEBUG)
+        run(host=LISTEN_ADDR, port=LISTEN_PORT, reloader=DEBUG)
         DB.close()
         DB.close()