Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/python-3.x/15.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 3.x python tornado如何获取边缘的id_Python 3.x_Tornado - Fatal编程技术网

Python 3.x python tornado如何获取边缘的id

Python 3.x python tornado如何获取边缘的id,python-3.x,tornado,Python 3.x,Tornado,我有一个在flask web框架上运行的web应用程序。Flask无法再满足应用程序要求。所以我们决定迁移龙卷风。 我需要处理以下两个请求 /entry GET Method /entry/id GET Method 当第一个请求被调用时,它必须返回经过身份验证的条目 调用第二个请求时,它必须返回其条目id为的条目 是身份证吗 除了我的解决方案之外,还有其他更好的解决方案来处理上述请求吗。我发现的解决方案是创建圈复杂度 def get(self): id = self.reque

我有一个在flask web框架上运行的web应用程序。Flask无法再满足应用程序要求。所以我们决定迁移龙卷风。 我需要处理以下两个请求

 /entry GET Method
 /entry/id GET Method
  • 当第一个请求被调用时,它必须返回经过身份验证的条目
  • 调用第二个请求时,它必须返回其条目id为的条目 是身份证吗
  • 除了我的解决方案之外,还有其他更好的解决方案来处理上述请求吗。我发现的解决方案是创建圈复杂度

    def get(self):
         id = self.request.path.split('/')[-1]
         if id is None:
             #return authenticated user
         else:
             #return the user whose entry_id is id
    
    注意:我正在寻找这样的解决方案:

    @rest_user.route('/user', methods=['GET'])
         #some code
    @rest_user.route('/user/<user_id>', methods=['GET'])
         #some code
    
    @rest\u user.route('/user',methods=['GET'])
    #一些代码
    @rest_user.route('/user/',methods=['GET'])
    #一些代码
    
    Tornado中类似的安排使用了两个处理程序类(可能有一个用于共享方法的公共基类):


    Tornado中类似的安排使用了两个处理程序类(可能有一个用于共享方法的公共基类):

    class AuthedUserHandler(RequestHandler):
        def get(self):
            ...
    
    class UserHandler(RequestHandler):
        def get(self, user_id):
            ...
    
    app = Application([
        ('/user', AuthedUserHandler),
        ('/user/(.*)', UserHandler),
    ])