Skip to content

Commit

Permalink
Optimate config item
Browse files Browse the repository at this point in the history
  • Loading branch information
noahziheng committed Mar 25, 2018
1 parent 6bc18e4 commit bd2a619
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 7 deletions.
6 changes: 3 additions & 3 deletions .env.sample
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# 全局配置
HOST = 127.0.0.1
PORT = 3000
DEBUG = true
APP_HOST = 127.0.0.1
APP_PORT = 3000
APP_DEBUG = true
FLASK_CONFIG = development
MONGO_HOST = localhost
MONGO_PORT = 27017
Expand Down
7 changes: 5 additions & 2 deletions libfreeiot/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,10 @@ def create_flask_app():
""" Function for create flask application instance """
return create_app(os.getenv('FLASK_CONFIG') or 'default')

def run(port = int(os.environ.get("PORT")), host = "0.0.0.0", adapters = None, app = None):
def run(port = int(os.environ.get("APP_PORT")),
host = os.environ.get('APP_HOST', '127.0.0.1'),
adapters = None,
app = None):
""" Main Method for running application """
if app is None:
app = create_flask_app() # Create Flask Application
Expand All @@ -27,4 +30,4 @@ def run(port = int(os.environ.get("PORT")), host = "0.0.0.0", adapters = None, a
adapter.init(app, scope) # Initialize all adapters
adapter.run() # Run all adapters

app.run(debug=os.environ.get("DEBUG") == "true", port=port, host=os.environ.get('HOST', '127.0.0.1')) # Start API services
app.run(debug=os.environ.get("APP_DEBUG") == "true", port=port, host=host) # Start API services
4 changes: 2 additions & 2 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,12 @@

setup(
name = "libfreeiot",
version = "0.9.4",
version = "0.9.5",
description = 'A free, open-source IoT Framework',
author = 'Noah Gao',
author_email = '[email protected]',
url = 'https://github.com/noahziheng/freeiot',
download_url = 'https://github.com/noahziheng/freeiot/archive/0.9.4.tar.gz',
download_url = 'https://github.com/noahziheng/freeiot/archive/0.9.5.tar.gz',
packages = find_packages(),
install_requires=[ # 依赖列表
'Flask>=0.12.2',
Expand Down

0 comments on commit bd2a619

Please sign in to comment.