in flask-restplus, I want to pass system call object: subprocess.call()
to GET
request to print out R session information on server endpoint. To do so, I think I need to add system call object to parser, which I hope api endpoint print out R session information. However, when I hit the code, I didn't see any printed session info on server endpoint. How can I correctly pass system.call()
to GET
request in order to print something out on endpoint? any idea?
my attempt:
here is the system call which can print out R session on python IDE console.
sess = subprocess.call(['C:/Program Files/R/R-3.6.3/bin/Rscript','--vanilla','-e','sessionInfo()'])
my attempt to pass sess to GET request:
from flask import Flask, jsonify
from flask_restplus import Api, Resource, fields, reqparse, inputs
import subprocess
app = Flask(__name__)
api = Api(app)
ns = api.namespace('sess')
sess = subprocess.call(['C:/Program Files/R/R-3.6.3/bin/Rscript','--vanilla','-e','sessionInfo()'])
@ns.route('/')
class AResource(Resource):
def get(self):
parser = reqparse.RequestParse()
parser.add_argument(sess, type= str, required=True)
#return parser.parse_args()
try:
args = parser.parse_args()
return jsonify(args)
except:
return None, 400
if __name__ == '__main__':
app.run(debug=True)
when I ran the code, I can't see any printed session information on the server endpoint. I think something wrong when I pass sess
object to GET request. How can I pass custom python function or object as a parameter to GET request in order to print out something on the server endpoint? any idea?
I am newbie to flask-restplus, so maybe I should not pass sess
to GET request like above. I humbly request for possible help. Thanks