我得到了一个错误405,你可以阅读,这是我的代码和我对错误的猜测。代码非常基本,它们是3个文件,main.py,blog.py和form.html。作为附加信息:此代码使用会话,子应用程序和模板。
main.py -
import web
import blog
urls = (
"/blog", blog.app_blog,
"/(.*)", "index"
)
web.config.debug = False
app = web.application(urls, locals())
session = web.session.Session(app, web.session.DiskStore('sessions'))
render = web.template.render('views/', globals = {'session': session})
class index:
def GET(self, path):
session.names = ''
session.surnames = ''
session.nin = ''
session.address = ''
session.phone = ''
session.email = ''
return render.form()
if __name__ == "__main__":
app.run()
-
blog.py -
import web
urls = (
"", "reblog",
"/", "blog"
)
class reblog:
def GET(self): raise web.seeother('/')
class blog:
def GET(self):
return "getblog"
def POST(self):
return "postblog"
app_blog = web.application(urls, locals())
- form.html -
<form method=post action=blog>
<ul>
<li><input name=names required maxlength=24 placeholder="Name" value="$session.names"></li>
<li><input name=surnames required maxlength=24 placeholder="Surname" value="$session.surnames"></li>
<li><input name=nin requiered maxlength=12 placeholder="RUT" value="$session.nin"></li>
<li><input name=address required maxlenght=64 placeholder="Address" value="$session.address"></li>
<li><input name=phone required maxlength=10 placeholder="Phone" value=$session.phone></li>
<li><input name=email type=email required maxlenght=254 placeholder="email" value=$session.email></li>
<li><input name=password type=password required placeholder="password"></li>
<li><input name=confirmpassword type=password required placeholder="Confirmar pass"></li>
<li><input type=submit value="registrarse"></li>
</ul>
问题是用户输入不是由POST使用,而是它给我一个错误405,如下所示: “HTTP / 1.1 POST / blog” - 405方法不允许
,浏览器打印无。
请给我一个帮手,如果你知道我的意思,这非常令人沮丧。
事先谢谢。
干杯。
答案 0 :(得分:1)
这是因为/blog
网址已映射到未定义class reblog
方法的POST
。