简体   繁体   English

Cloud9 Python XMLRPC Server 302重定向

[英]Cloud9 Python XMLRPC Server 302 redirect

I'm using python and cloud9 trying to setup a simple XMLRPC server. 我正在使用python和cloud9尝试设置一个简单的XMLRPC服务器。 If I run this all on my local host, I have no issues. 如果我全部在本地主机上运行,​​则不会有任何问题。 On the Cloud9 host, I get get a ProtocolError 302 Moved temporarily. 在Cloud9主机上,我收到一个ProtocolError 302临时移动。

Any ideas? 有任何想法吗?

The server code is: 服务器代码为:

from SimpleXMLRPCServer import SimpleXMLRPCServer
import logging
import os

ip = os.getenv("IP", "0.0.0.0")
port = int(os.getenv("PORT", 8080))

logging.basicConfig(level=logging.DEBUG)

server = SimpleXMLRPCServer((ip, port), logRequests=True)

def list_contents(dir_name):
    logging.debug('list_contents(%s)', dir_name)
    return dir_name
server.register_function(list_contents)

try:
    print 'Use Control-C to exit'
    server.serve_forever()
except KeyboardInterrupt:
    print 'Exiting'

The client code is: 客户端代码为:

import xmlrpclib

url = "https://xxxxx.c9.io/"
srv = xmlrpclib.ServerProxy(url, verbose=True)
print srv.list_contents("asdf")

The 302 response is most likely redirecting you to an authentication/authorisation URL to assess your permissions to access the application. 302响应很可能会将您重定向到身份验证/授权URL,以评估您访问应用程序的权限。 This is always the response if you configured your workspace / access via web to be private (no unauthenticated access). 如果您将工作空间/通过Web的访问配置为私有(没有未经身份验证的访问),则始终是响应。

You can either share it publicly (click Share -> click 'application' to be public) or provide username and password in the requested URL in the client: 您可以公开共享(单击共享->单击“应用程序”以公开),也可以在客户端请求的URL中提供用户名和密码:

url = "https://username:password@workspace-c9-user.c9.io/" 

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM