我有一个python脚本,可以进行多个API调用。我可以获取模板并输入数据,但是当我提交数据时,没有返回数据或提交工作不正常,脚本是否有问题。似乎POST调用在脚本中不起作用
from flask import Flask, render_template, request, jsonify
from pshell import fetchDriveInfo, checkUserGroup
import subprocess, sys
#import json
app = Flask(__name__)
@app.route("/")
def index():
x = checkUserGroup()
if "***" in x:
return render_template("error.html")
else:
return render_template("index.html")
@app.route('/formData', methods=['POST'])
def sendInfo():
y = jsonify(request.json)
request_json = request.get_json()
case_var = request_json.get('case')
id_var = request_json.get('id')
fetchDriveInfo(case_var, id_var)
return y
@app.route("/formStats")
def showPage():
variable = "Hello!"
return render_template("stats.html", var = variable)
if __name__ == '__main__':
app.run(host='0.0.0.0',port=5000)