2016-11-13 22 views
-1

我正在關注this guide (Python Quickstart: Replying to SMS and MMS Messages)嘗試設置瓶服務器,但是當我嘗試連接到http://localhost:5000時,出現404錯誤。我可以ping 127.0.0.1沒問題。Flask服務器在localhost上返回404:ww Twilio

代碼:

from flask import Flask, request, redirect 
import twilio.twiml 

app = Flask(__name__) 

@app.route("/", methods=['GET', 'POST']) 
def hello_monkey(): 
    """Respond to incoming calls with a simple text message.""" 

    resp = twilio.twiml.Response() 
    resp.message("Hello, Mobile Monkey") 
    return str(resp) 

if __name__ == "__main__": 
    app.run(debug=True) 

控制檯輸出:

* Running on http://127.0.0.1:5000/ (Press CTRL+C to quit) 
* Restarting with windowsapi reloader 

localhost 404'ing

+0

您是否在控制檯輸出中看到任何消息?你是否在服務器的同一臺計算機上運行瀏覽器? – furas

+0

我將我在控制檯中看到的所有內容放在我的帖子中。我在與服務器相同的計算機上運行瀏覽器。 –

回答

0

我可以重新啓動我的電腦後,連接到http://127.0.0.1:5000/。不知道是什麼導致了這個問題。

+0

一個顯而易見的區別是,在重新啓動之後,您使用的是「http:// localhost:5000」,但使用了「http://127.0.0.1:5000 /」。 – mhawke

+0

我嘗試在重新啓動之前加載它,它沒有什麼區別。 –

相關問題