经过广泛搜索后,我无法为我简单的扭曲网站添加身份验证。该站点接受Web get并枚举它传递的参数。这就是我正在使用的。在接受Web get请求之前,只有一个用户需要进行身份验证,因此我不确定域是否适用于这种情况。任何建议都将不胜感激。
from twisted.web import server, resource
from twisted.internet import reactor, task
class Simple(resource.Resource):
isLeaf = True
allowedMethods = ('GET',)
def render_GET(self, request):
try:
print(request)
urlstring = request.content.read()
print (urlstring)
print (request.content.read())
print request.args
print "User=", request.getUser()
print "Pass=", request.getPassword()
except Exception, exception:
print "Unexpected error", exception.args
return "200 ok"
site = server.Site(Simple())
reactor.listenTCP(8080, site, interface='')
reactor.run()
答案 0 :(得分:1)
Twisted Web的HTTP身份验证记录在https://twistedmatrix.com/documents/current/web/howto/web-in-60/http-auth.html
中