From 3bcf46269ab470046cfc7b374216798a2977f0fe Mon Sep 17 00:00:00 2001 From: Walker Waylon Scott Date: Thu, 29 Jun 2017 23:54:11 -0500 Subject: [PATCH] simplifying if __name__ == '__main__' --- src/pyDataVizDay.py | 15 +++------------ 1 file changed, 3 insertions(+), 12 deletions(-) diff --git a/src/pyDataVizDay.py b/src/pyDataVizDay.py index 98c3e25..d4efb3f 100644 --- a/src/pyDataVizDay.py +++ b/src/pyDataVizDay.py @@ -6,6 +6,7 @@ IMDB 5000 Movie Dataset. """ +import os from flask import Flask from flask import request, render_template, make_response, jsonify @@ -24,16 +25,6 @@ def investor(): def enthusiast(): return render_template('enthusiast.html', body='Hello Enthusiast') - - - if __name__ == '__main__': - import argparse - parser = argparse.ArgumentParser(description='pyDataVizDay') - parser.add_argument('--port', default='5000') - parser.add_argument('--debug', dest='debug', action='store_true') - parser.add_argument('--no_debug', dest='debug', action='store_false') - parser.set_defaults(debug=False) - args = parser.parse_args() - # webbrowser.open('http://' + str(host) + ':' + str(port) + '/') - app.run(debug=args.debug, host='0.0.0.0', port=int(args.port)) \ No newline at end of file + port = int(os.environ.get("PORT", 5000)) + app.run(host='0.0.0.0', port=port) \ No newline at end of file