web.py form表单填写内容,通过post方法提交,为什么老提示" POST /add" - 405 Method Not Allowed
html代码:$defwith(user)<ul>$forUserinuser:<li>$User.user_name,$User.user_id,$User.accou...
html代码:
$def with (user)
<ul>
$for User in user:
<li>$User.user_name,$User.user_id,$User.account,$User.password</li>
</ul>
<form method="post" action="add">
<input type="text" name="user_name"/>
<input type="text" name="account"/>
<input type="text" name="password"/>
<input type="submit" vlaue="提交"/>
</form>
python代码:
#-*- coding: utf-8 -*-
import web
import sqlite3
from web import form as form
render=web.template.render('templates/')
urls = (
'/', 'index',
'/add','add'
)
db = web.database(dbn='sqlite', db='BMS.db')
app = web.application(urls, globals())
class index:
def GET(self):
user=db.select("User")
print user
return render.index(user)
#return len(list(user1))
class add:
def Post(self):
i=web.input()
name,account,password=i.name,i.account,i.password
n=db.insert('Book',book_name='name',account='account',password='password')
raise web.seeother("/")
if __name__ == "__main__":
app.run() 展开
$def with (user)
<ul>
$for User in user:
<li>$User.user_name,$User.user_id,$User.account,$User.password</li>
</ul>
<form method="post" action="add">
<input type="text" name="user_name"/>
<input type="text" name="account"/>
<input type="text" name="password"/>
<input type="submit" vlaue="提交"/>
</form>
python代码:
#-*- coding: utf-8 -*-
import web
import sqlite3
from web import form as form
render=web.template.render('templates/')
urls = (
'/', 'index',
'/add','add'
)
db = web.database(dbn='sqlite', db='BMS.db')
app = web.application(urls, globals())
class index:
def GET(self):
user=db.select("User")
print user
return render.index(user)
#return len(list(user1))
class add:
def Post(self):
i=web.input()
name,account,password=i.name,i.account,i.password
n=db.insert('Book',book_name='name',account='account',password='password')
raise web.seeother("/")
if __name__ == "__main__":
app.run() 展开
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询