flask를 이용해 파이썬 웹서버 만들기
일단 pip를 이용해 flask를 설치한다. 아래와 같은 코드를 돌리면 hello.html 파일을 게시할 수 있다. 다만 이 html파일은 templates라는 서브 폴더 안에 들어가 있어야 한다. ip주소:5000으로 웹브라우저에서 돌리면 hello.html파일을 볼 수 있다. from flask import Flask, render_templateapp = Flask(__name__) @app.route("/")def hello():return render_template('hello.html') if __name__ == "__main__": app.run(host='0.0.0.0', port=5000, debug=True)
카테고리 없음
2016. 10. 17. 18:04