2017-02-01 80 views
0

= 我正在學習python的書籍」學習python的硬性方法「 我正在做web練習,但我無法找到一個concret信息。python web.py HTTP/1.1 GET /「-404 Not Found

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> 

好,我不能進入行動= 「/你好」。

但我可以acces與行動=「/」以及我不知道這是什麼原因

有人能解釋我嗎?

回答

0

當你運行你app.py BU默認你在這裏指導:

http://0.0.0.0:8080/

但對你說「找不到文件」,因爲你必須去這裏:

http://0.0.0.0:8080/hello

所以要麼你改變你的app.py只保留/在你的網址 要麼手動添加/你好在你的網址。

乾杯,

的Filiberto