summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorprashantsinalkar2019-12-19 11:28:51 +0530
committerprashantsinalkar2019-12-19 11:28:51 +0530
commitdbc9ec1953fb965691550c5989992881b7658f04 (patch)
tree74c654d579013a338e897e6939f43df6f0b39b5c
parent2eac156049b51312c20d24ccd0e57b0fe62c0ecd (diff)
downloadR_on_Cloud_Flask_Web_API-dbc9ec1953fb965691550c5989992881b7658f04.tar.gz
R_on_Cloud_Flask_Web_API-dbc9ec1953fb965691550c5989992881b7658f04.tar.bz2
R_on_Cloud_Flask_Web_API-dbc9ec1953fb965691550c5989992881b7658f04.zip
updated the code for api connectionHEADmaster
-rw-r--r--r_api.py18
-rw-r--r--requirements.txt1
2 files changed, 13 insertions, 6 deletions
diff --git a/r_api.py b/r_api.py
index 9dbd83e..0725e22 100644
--- a/r_api.py
+++ b/r_api.py
@@ -3,6 +3,7 @@ import subprocess
import flask
from flask import send_file
from flask import Flask, url_for, jsonify, request
+from flask_api import status
from werkzeug import secure_filename
import json
import os
@@ -18,14 +19,19 @@ if not os.path.exists(TEMP_DIR):
app = Flask(__name__)
+# @app.route('/')
+# def api_root():
+# headers = request.headers
+# auth = headers.get("X-Api-Key")
+# if auth == AUTH_KEY:
+# return jsonify({"message": "OK: Authorized"}), 200
+# else:
+# return jsonify({"message": "ERROR: Unauthorized"}), 401
+
@app.route('/')
def api_root():
- headers = request.headers
- auth = headers.get("X-Api-Key")
- if auth == AUTH_KEY:
- return jsonify({"message": "OK: Authorized"}), 200
- else:
- return jsonify({"message": "ERROR: Unauthorized"}), 401
+ content = {'status': status.HTTP_200_OK}
+ return content, status.HTTP_200_OK
@app.route('/rscript', methods=['GET', 'POST'])
diff --git a/requirements.txt b/requirements.txt
index 5c1bea9..cc928eb 100644
--- a/requirements.txt
+++ b/requirements.txt
@@ -1,2 +1,3 @@
flask
flask-session
+flask_api