commit 3a333c18653bbf6244c5df42b2aca7eead59776c
| author | 斟酌 鵬兄 <tgckpg@gmail.com> |
| date | 2016-05-30T04:29:30Z |
| subject | Settings added bind address and port |
commit 3a333c18653bbf6244c5df42b2aca7eead59776c
Author: 斟酌 鵬兄 <tgckpg@gmail.com>
Date: 2016-05-30T04:29:30Z
Settings added bind address and port
---
botanjs/service/webapi.py | 10 +++++-----
settings.ini | 4 ++++
2 files changed, 9 insertions(+), 5 deletions(-)
diff --git a/botanjs/service/webapi.py b/botanjs/service/webapi.py
index 4626a0c..08b238d 100755
--- a/botanjs/service/webapi.py
+++ b/botanjs/service/webapi.py
@@ -4,7 +4,7 @@ from flask import Response
from flask import render_template
from botanjs.service.jclassresv import BotanClassResolver as JCResv
from botanjs.service.jwork import app as CeleryApp, JWork
-from botanjs.config import DEBUG
+from botanjs.config import Config, DEBUG
import os
@@ -32,7 +32,10 @@ class WebAPI:
self.app.add_url_rule( "/" , view_func = self.index )
self.app.add_url_rule( "/<path:mode>/<path:code>" , view_func = self.api_request )
- self.app.run( host = "0.0.0.0", debug = DEBUG )
+ self.app.run(
+ host = Config[ "Service" ][ "BindAddress" ]
+ , port = int( Config[ "Service" ][ "Port" ] )
+ , debug = DEBUG )
def index( self ):
return "Hello, this is the BotanJS Service API.", 200
@@ -52,6 +55,3 @@ class WebAPI:
return "Invalid request", 404
-
-if __name__ == "__main__":
- WebAPI()
diff --git a/settings.ini b/settings.ini
index 1568871..358d491 100644
--- a/settings.ini
+++ b/settings.ini
@@ -1,3 +1,7 @@
+[Service]
+BindAddress = 0.0.0.0
+Port = 5000
+
[Env]
Debug = True