Flask 서버 실행

sunj - May 10 - - Dev Community
#hello.py
from flask import Flask
app = Flask(__name__)

@app.route('/')
def index():
    return 'Index Page'

@app.route('/hello')
def hello_world():
    return 'Hello World!'

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

Enter fullscreen mode Exit fullscreen mode
#venv 실행 상태에서
python hello.py
Enter fullscreen mode Exit fullscreen mode

서버는 127.0.0.1:5000에서 실행 포트 변경도 가능

..
app.run(port=5001)
Enter fullscreen mode Exit fullscreen mode

코드 변경 시마다 리로드하고 싶으면 디버그모드 하면되는데, 운영서버에서는 절대 불가

app.run(debug=True)
Enter fullscreen mode Exit fullscreen mode

참조: 유투브 생활코딩

. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Terabox Video Player