Python错误值错误:视图函数未返回响应

2024-04-25 04:16:53 发布

您现在位置:Python中文网/ 问答频道 /正文

我的应用程序在运行错误值error:View函数的url http://localhost:81/ip_update/00178r时没有返回响应。 我无法解决,如果有人能帮我,我将非常感激

def ip_update (client):
    ip = request.remote_addr
    if 'r' in client:
        customer = cliente.rstrip ('r')
        urllib2.urlopen ('http://localhost:85/administration/ip_update/' + client + '/' + ip)
        time.sleep (3)
    else:
        server = 'localhost'
        port = 3306
        login = root
        password = 'password'

        mdb.connect con = (host = server, port = port = user login, passwd = password, use_unicode = True)
        cur = con.cursor ()

        cur.execute ("SELECT FROM tar_cliente ebas.tarefa WHERE tar_status = 'processing' and tar_cliente = '" + client $

        if cur.rowcount == 0:
            Data2 data = ()
            server = data2 ['clients'] [customer] ['server']
            urllib2.urlopen ('http://' + server + '/administration/ip_update/' + client + '/' + ip)
            time.sleep (3)
            return 'request for ip received for updating client code' + client
        else:
            return 'denied updating, client operation underway'

Tags: ipclientlocalhosthttpifserverportrequest
1条回答
网友
1楼 · 发布于 2024-04-25 04:16:53

if测试为真时,函数返回None

if 'r' in client:
    customer = cliente.rstrip ('r')
    urllib2.urlopen ('http: // localhost: 85 / administration / ip_update /' + client + '/' + ip)
    time.sleep (3)

在这种情况下,你也需要返回一个响应。在这里使用sleep没有任何意义;您所做的只是延迟将某些内容返回到浏览器。在

相关问题 更多 >