2017-12-23 4 views
0

를 찾을 수 없습니다이 내 코드입니다플라스크 - 404 나는 이것이 내 첫 번째 프로그램은 플라스크에 플라스크 개발 안돼서하지만 나에게이 오류 표시

The requested URL was not found on the server. If you entered the URL manually please check your spelling and try again.

&을

from flask import Flask 

app = Flask(__name__) 


@app.route('/index') 
def index(): 
    return 'Hello World' 


if __name__ == '__main__': 
    app.run(debug=True) 
+0

시도하려는 URL이 무엇인가요? '/ index'이어야합니다. – karthikr

+0

'http : // localhost : 5000/index'로 갔습니까? – Abdou

+0

프로그램을 실행할 때 pycharm을 사용하고 있습니다.이 링크는 "http://127.0.0.1:5000/"에서 실행 중입니다. " –

답변

0

나는 당신이 http://localhost:5000/index 또는 http://127.0.0.1:5000/index에 가야한다고 생각하지만 그 페이지를 만들고 싶다면 코드는 이와 같아야한다.

from flask import Flask 

app = Flask(__name__) 


@app.route('/') 
def index(): 
    return 'Hello World' 


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

변경 @app.route('/index') ~ @app.route('/')도 확인해야합니다. http://flask.pocoo.org/docs/0.12/quickstart/#routing

+0

하지만이 코드가 작동하지 않는 이유는 무엇입니까? –

+0

http를 요청하면 어떻게됩니까? : // localhost : 5000 /'반환하는 내용을 의미합니다. –

+0

코드가 완벽하게 작동하지만 내 이유가 없습니다. –