Parcourir la source

allows to configure listeting port and addr fixes #8

Jocelyn Delande il y a 10 ans
Parent
commit
a620f59770
2 fichiers modifiés avec 10 ajouts et 1 suppressions
  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
 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
 ===================
 

+ 3 - 1
backend.py

@@ -353,6 +353,8 @@ def build_geojson():
 
 
 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 len(sys.argv) > 1:
@@ -361,5 +363,5 @@ if __name__ == '__main__':
         if sys.argv[1] == 'buildgeojson':
             build_geojson()
     else:
-        run(host='localhost', port=8080, reloader=DEBUG)
+        run(host=LISTEN_ADDR, port=LISTEN_PORT, reloader=DEBUG)
         DB.close()