FLASK 웹 사이트 만들기 1

FLASK 웹 사이트 만들기 1
1. 구름 IDE 접속
2. 컨테이너 생성
Name : BUILD
Description : house build Web Site
Region : Seoul(KOR)
Visibility : Private
Template : Default Template
Deployment : Not used
Stack : Flask

3. 컨테이너 생성 완료 화면 → Run Container 버튼 마우스로 클릭

4. PROJECT → Running URL and Port

5. Propety → Running URL and Port → Port 80 Delete

6. URL & PORT 입력 후 Register 버튼 마우스로 클릭
URL : https:// housetest
PORT : 5000

7. application.py default code
from flask import Flask import sys application = Flask(__name__) @application.route("/") def hello(): return "Hello goorm!" if __name__ == "__main__": application.run(host='0.0.0.0', port=int(sys.argv[1]))
8. templates 폴더 생성 → hello.html 생성
<h1> hello </h1>
9. application.py update code
from flask import Flask, render_template import sys application = Flask(__name__) @application.route("/") def hello(): return render_template("hello.html") if __name__ == "__main__": application.run(host='0.0.0.0')
10. TERMINAL → python3 application.py 실행 확인
* local일 경우 - http://0.0.0.0:5000/ 링크 클릭
* goorm IDE일 경우 - 11~12번 참고

11. PROJECT → Running URL and Port

12. Propety → Running URL and Port → Registed URL and Port → URL 링크 바로가기 버튼 마우스로 클릭
URL - https://housetest.run.goorm.io

13. 홈페이지 확인

출처
* FLASK 이미지 : https://ko.wikipedia.org/wiki/%ED%94%8C%EB%9D%BC%EC%8A%A4%ED%81%AC_(%EC%9B%B9_%ED%94%84%EB%A0%88%EC%9E%84%EC%9B%8C%ED%81%AC)
클론코딩 강의 : https://www.youtube.com/watch?v=hsfibrhGFiM&list=PLqIc89sXpwUBmr0Z282fm9JurDDYBE55r&index=2
'Python > FLASK' 카테고리의 다른 글
[FLASK] 웹 사이트 만들기 2 (0) | 2022.04.11 |
---|