post方法返回都是none
。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。
import web
? ? ? ??
urls = (
'/index','index',
'/blog/\d','blog',
? ? '/(.*)', 'hello'
)
app = web.application(urls, globals())
class index:
def GET(self):
query=web.input()
return query
class blog:
def POST(self):
data=web.input()
return data
class hello:? ? ? ??
? ? def GET(self, name):
? ? ? ? return open(r'new2.html').read()
if __name__ == "__main__":
? ? app.run()
。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。
<!DOCTYPE HTML>
<html><head meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>小型demo</title>
</head>
<body>
<h1>POST</h1>
<form action="/blog/123" method="POST">
<input type="text" name="id" value=""/>
<input type="password" name="password" value=""/>
<input type="submit" value="submit"/>
</form>
</body>
</html>
??
上面分別是html和python的源碼,網(wǎng)頁返回的都是none
2018-09-18
那你在地址欄輸入的什么呢?
如果你輸入的是可以匹配上這個(gè)的'/blog/\d','blog',那么頁面可能會(huì)返回none;
如果想找到那個(gè)表單界面,只需要匹配?'/(.*)', 'hello',然后輸入用戶名密碼,提交后地址欄就會(huì)變成http://127.0.0.1:8080/blog/123,但是由于你上面寫的是\d,但是\d只能匹配上一個(gè)數(shù)字。。你可以試試改成\d+,或者吧html頁面的<form action="/blog/123" method="POST">改成<form action="/blog/1" method="POST">