From 688be51a2e3a380e57423ac6e7044e997635a8dd Mon Sep 17 00:00:00 2001 From: Sean McArdle Date: Mon, 5 Nov 2018 16:18:27 -0800 Subject: [PATCH] Doesnt work but may be getting somewhere. --- .vscode/launch.json | 64 +++++++++++++++++++++++++++++++++++++++++++++++++++++ run_app.cmd | 2 +- src/claims.py | 22 ++++++++++-------- 3 files changed, 78 insertions(+), 10 deletions(-) create mode 100644 .vscode/launch.json diff --git a/.vscode/launch.json b/.vscode/launch.json new file mode 100644 index 0000000..1d2da4b --- /dev/null +++ b/.vscode/launch.json @@ -0,0 +1,64 @@ +{ + // Use IntelliSense to learn about possible attributes. + // Hover to view descriptions of existing attributes. + // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387 + "version": "0.2.0", + "configurations": [ + { + "name": "Python: Current File (Integrated Terminal)", + "type": "python", + "request": "launch", + "program": "${file}", + "console": "integratedTerminal" + }, + { + "name": "Python: Attach", + "type": "python", + "request": "attach", + "port": 5678, + "host": "localhost" + }, + { + "name": "Python: Module", + "type": "python", + "request": "launch", + "module": "enter-your-module-name-here", + "console": "integratedTerminal" + }, + { + "name": "Python: Django", + "type": "python", + "request": "launch", + "program": "${workspaceFolder}/manage.py", + "console": "integratedTerminal", + "args": [ + "runserver", + "--noreload", + "--nothreading" + ], + "django": true + }, + { + "name": "Python: Flask", + "type": "python", + "request": "launch", + "module": "flask", + "env": { + "FLASK_APP": "claims.py" + }, + "args": [ + "run", + "--no-debugger", + "--no-reload" + ], + "jinja": true + }, + { + "name": "Python: Current File (External Terminal)", + "type": "python", + "request": "launch", + "program": "${file}", + "console": "externalTerminal" + } + ] +} \ No newline at end of file diff --git a/run_app.cmd b/run_app.cmd index 05fa8bd..f1672e5 100644 --- a/run_app.cmd +++ b/run_app.cmd @@ -1,4 +1,4 @@ @echo off set FLASK_ENV=development set FLASK_APP=src/claims.py -flask run \ No newline at end of file +python %FLASK_APP% \ No newline at end of file diff --git a/src/claims.py b/src/claims.py index ae6d926..b3f2c97 100644 --- a/src/claims.py +++ b/src/claims.py @@ -1,6 +1,8 @@ #!/usr/bin/env python3 import flask +import json +from flask import jsonify from flask import request from flask import render_template @@ -17,20 +19,18 @@ def hello_world(): return "Hello world!" -@app.route('/claims/saml/', methods=['POST', 'GET']) -def get_saml_claims(foo): +@app.route('/claims/saml', methods=['POST', 'GET']) +def get_saml_claims(): error = None if request.method == 'POST': - r = request - pass + return json.dumps(request.get_data(), sort_keys=True) if request.method == 'GET': - # - pass - return render_template('claims.html', error=error) + return "Dude where's my claims?" + @app.route('/claims/oauth/', methods=['POST', 'GET']) -def get_oauth_claims(foo): +def get_oauth_claims(): error = None if request.method == 'POST': # handle claims token @@ -38,4 +38,8 @@ def get_oauth_claims(foo): if request.method == 'GET': # pass - return render_template('claims.html', error=error) \ No newline at end of file + return render_template('claims.html', error=error) + + +if __name__ == "__main__": + app.run(ssl_context='adhoc') \ No newline at end of file