0

我刚开始学习烧瓶,我被这个错误困住了。我在这里检查了很多这样的问题,但我不确定我的代码有什么问题。

from flask import Flask,url_for
from flask import make_response
from flask import request
from flask import render_template
from WebService.application import deploy_azure

app = Flask(__name__)

@app.route('/', methods=['GET'])
def my_form():
    return render_template("xyz.html")


@app.route('/', methods=['POST'])
def login():
    data = request.form['text']
    resp = make_response(deploy_azure.deploy_function(data))
    return resp


if __name__ == '__main__':
    app.debug = True
    app.run()      
4

1 回答 1

0

If I understood you correctly and you want to return a string returned by the deploy_function method in the flask view then just return it. Don't use make_response in this case. Your method should look like this:

@app.route('/', methods=['POST'])
def login():
    data = request.form['text']
    return deploy_azure.deploy_function(data)

You also have the same route defined for two different view functions. Although it will work, but it's better to use different routes for different functions.

于 2017-06-28T08:37:18.037 回答