如您所见,我收到错误 405,这是我的代码和我对问题的猜测。代码非常基本,它们是 3 个文件,main.py、blog.py 和 form.html。作为附加信息:此代码使用会话、子应用程序和模板。
主要.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()
--
博客.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 Method Not Allowed
并且浏览器打印无。
伙计们,请帮帮我,这很令人沮丧,如果你知道我的意思的话。
预先感谢。
干杯。