Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/294.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python 两个应用程序路由到同一功能的处理POST方法_Python_Flask_Routes - Fatal编程技术网

Python 两个应用程序路由到同一功能的处理POST方法

Python 两个应用程序路由到同一功能的处理POST方法,python,flask,routes,Python,Flask,Routes,我怎样才能让这样的东西发挥作用 @app.route('/client_progress') @app.route('/client_update', methods=['POST', 'GET']) def func_1(): if (//app.route == client_progress) if request.method == 'POST': return 'hello world' elif (//app.route =

我怎样才能让这样的东西发挥作用

@app.route('/client_progress')
@app.route('/client_update', methods=['POST', 'GET'])
def func_1():
    if (//app.route == client_progress)
        if request.method == 'POST':
             return 'hello world'

    elif (//app.route == client_update)
        if request.method == 'POST':
             return 'Good World'
我想有两个应用程序路线相同的功能,并能够回应回适当的路线


这可能吗?如果是,请分享示例。

这是可能的,但毫无意义。为什么要将2条不同的路由分组到同一个函数中,只是为了根据同一个函数中的路由分割逻辑?为什么不首先为每个路由使用不同的函数呢?因为我想要共享值,比如说,如果我为两个应用路由创建两个函数,并且假设func_1处理一个客户端名称,那么如果其他应用路由的func_2不共享资源,它们将如何识别此信息?本质上,func_1处理客户端,func_2在浏览器中显示此客户端(如果有意义的话)。无论您尝试实现什么,都必须有更好的选项。为了得到更好的答案,你需要提供一个更好的例子。到目前为止,这是一个问题。