【问题标题】:Using xmlrpc in web2py for command line interface for a web application在 web2py 中使用 xmlrpc 作为 Web 应用程序的命令行界面
【发布时间】:2011-06-16 16:23:02
【问题描述】:

我在 web2py 中有一个应用程序。要创建 gui 的命令行界面(web-interface),我想使用 xmlrpc 服务。例如,如果我有以下功能:

@auth.requires_login
def example():
    temp = request.args[0]
    //do something on temp
    return dict(temp=temp)

如何在 xmlrpc 中调用此函数,以便对原始函数定义进行最小的更改(我需要进行身份验证,以某种方式发送请求变量,并返回一些数据结构)。

【问题讨论】:

    标签: python xml-rpc command-line-interface web2py


    【解决方案1】:

    您需要使用服务来通过 xmlrpc 公开功能

    auth.settings.allow_basic_login = True
    
    @service.xmlrpc
    def example(temp):
        return ...
    
    
    @auth.requires_login()
    def call(): return service()
    

    您可以在书中阅读更多内容。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2010-11-23
      • 2021-06-01
      • 1970-01-01
      • 1970-01-01
      • 2015-09-27
      • 2014-05-19
      • 2016-01-18
      • 2012-05-18
      相关资源
      最近更新 更多