From d3575a29d59b0c2f20fd233754ea25677399ff2d Mon Sep 17 00:00:00 2001 From: Jeremy Zhang Date: Fri, 31 Mar 2017 07:34:06 +0000 Subject: [PATCH] Add Cloud9 development running support --- run.py | 10 ++++++---- run_c9.py | 6 ++++++ 2 files changed, 12 insertions(+), 4 deletions(-) create mode 100644 run_c9.py diff --git a/run.py b/run.py index bae49e7..6df3c74 100644 --- a/run.py +++ b/run.py @@ -1,11 +1,12 @@ #!/usr/bin/env python2 from titanembeds.app import app -if __name__ == "__main__": +def init_debug(): import os from flask import jsonify, request + os.environ['OAUTHLIB_INSECURE_TRANSPORT'] = '1' # Testing oauthlib - + # Session viewer https://gist.github.com/babldev/502364a3f7c9bafaa6db def decode_flask_cookie(secret_key, cookie_str): import hashlib @@ -19,7 +20,7 @@ if __name__ == "__main__": } s = URLSafeTimedSerializer(secret_key, salt=salt, serializer=serializer, signer_kwargs=signer_kwargs) return s.loads(cookie_str) - + @app.route("/session") def session(): cookie = request.cookies.get('session') @@ -29,5 +30,6 @@ if __name__ == "__main__": decoded = None return jsonify(session_cookie=decoded) - +if __name__ == "__main__": + init_debug() app.run(host="0.0.0.0",port=3000,debug=True) diff --git a/run_c9.py b/run_c9.py new file mode 100644 index 0000000..1597f6a --- /dev/null +++ b/run_c9.py @@ -0,0 +1,6 @@ +from run import app, init_debug +import os + +if __name__ == "__main__": + init_debug() + app.run(host=os.getenv('IP', '0.0.0.0'), port=int(os.getenv('PORT', 8080)), debug=True) \ No newline at end of file