Commit 8aec4f55 authored by robert.vincze's avatar robert.vincze

TVB-2593: Made Flask able to run in both modes dependeing on TvbProfile.is_distribution().

parent a23e5252
FLASK_ENV=development
\ No newline at end of file
......@@ -46,8 +46,7 @@ from tvb.interfaces.rest.server.resources.project.project_resource import GetOpe
from tvb.interfaces.rest.server.resources.simulator.simulation_resource import FireSimulationResource
from tvb.interfaces.rest.server.resources.user.user_resource import GetUsersResource, GetProjectsListResource
from tvb.interfaces.rest.server.rest_api import RestApi
from dotenv import load_dotenv
# from gevent.pywsgi import WSGIServer
from gevent.pywsgi import WSGIServer
TvbProfile.set_profile(TvbProfile.COMMAND_PROFILE)
......@@ -57,9 +56,7 @@ LOGGER.info("TVB application will be running using encoding: " + sys.getdefaulte
FLASK_PORT = 9090
# Comment these lines when running in production mode
dotenv_path = os.path.join(os.path.dirname(__file__), '.env')
load_dotenv(dotenv_path)
os.environ['FLASK_ENV'] = 'development'
def initialize_tvb(arguments):
......@@ -136,10 +133,11 @@ def initialize_flask():
api.add_namespace(name_space_operations)
api.add_namespace(name_space_simulation)
# Uncomment these lines and comment app.run... for running Flask in production mode
# http_server = WSGIServer(("0.0.0.0", FLASK_PORT), app)
# http_server.serve_forever()
app.run(host="0.0.0.0", debug=True, port=FLASK_PORT)
if TvbProfile.env.is_distribution():
http_server = WSGIServer(("0.0.0.0", FLASK_PORT), app)
http_server.serve_forever()
else:
app.run(host="0.0.0.0", debug=True, port=FLASK_PORT)
if __name__ == '__main__':
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment