Python Error ValueError:View函数未返回响应

时间:2015-07-08 18:33:07

标签: python flask

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

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'

1 个答案:

答案 0 :(得分:2)

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

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

在这种情况下你也需要回复一个回复。在这里使用睡眠毫无意义;你所做的就是推迟向浏览器返回内容。