无法从相同python文件的另一个flask方法调用flask方法。例如,考虑下面的代码
@app.route('/api/v1/employee/add', method = ['POST'])
def add_employee():
req = request.json
#add the employee to db
@app.route('/api/v1/employee', method = ['GET'])
def get_employee():
data = json.loads(employee) #getting employee details from db
add_employee() # unable to call this method as I am getting the data as null.
如何解决此问题
def add_employee():
@app.route('/api/v1/employee/add', method = ['POST'])
def http_employee():
req = request.json
add_employee()
#add the employee to db
@app.route('/api/v1/employee', method = ['GET'])
def get_employee():
data = json.loads(employee) #getting employee details from db
add_employee() # unable to call this method as I am getting the data as null.