【问题标题】:Python web.py HTTP/1.1 GET /" -404 Not FoundPython web.py HTTP/1.1 GET /" -404 未找到
【发布时间】:2021-05-04 07:58:08
【问题描述】:

我正在通过“Learn python the hard way”这本书来学习 python 我正在做网络练习,但找不到具体信息。

import web

urls =( '/hello', 'Index')
app = web.application(urls,globals())
render = web.template.render(<mypath>)

class Index(object):

def GET(self):
   return render.hello_form()

def POST(self):
    form  = web.input(name="Nobody", greet="Hello")
    greeting = "%s, %s" %(form.greet, form.name)
    return render.index(greeting = greeting)

然后...在我的“hello_form”中

<form action="/hello" method="POST">
A greeting <input type=text" name="greet">
<br/>
Your Name:  <input type="text" name="name">
<br/>
<input type="submit>
</form>

好吧,我无法访问 action="/hello"。

但我可以通过 action="/" 访问,我不知道是什么原因

谁能解释一下?

【问题讨论】:

    标签: python web


    【解决方案1】:

    当你运行你的 app.py 时,默认你会被引导到这里:

    http://0.0.0.0:8080/

    但它对你说“找不到文件”,因为你必须去这里:

    http://0.0.0.0:8080/hello

    所以要么你改变你的 app.py 只保留 / 在你的网址 您可以在 URL 中手动添加 /hello。

    干杯,

    菲利伯托

    【讨论】:

      猜你喜欢
      • 2019-09-09
      • 2023-03-11
      • 1970-01-01
      • 2020-03-03
      • 2016-04-11
      • 2014-01-16
      • 2018-08-01
      • 2017-06-14
      相关资源
      最近更新 更多