-
[python][flask] 웹서버 - 다중 페이지 구현하기프로그래밍/Python 2021. 1. 15. 18:25
작업환경 : vs code
작업버전 : python 3.8.6 64-bit
날짜 : 21.01.14
소스코드
from flask import Flask app = Flask(__name__) # 플라스크 앱 생성 # 기본('/') 웹주소로 요청이 오면 @app.route('/') def hello(): # hello 함수 실행 return 'Hello world2' # '/about'으로 접속되었을 때 @app.route('/about') def about(): # about 함수 실행 return 'This is about page' # '/contact'로 접속되었을 때 @app.route('/contact') def contact(): # about 함수 실행 return 'This is contact page' if __name__ == '__main__': #main 함수 app.run(debug=True, port=80, host='0.0.0.0') # debug : True이면 코드가 변경될때마다(저장포함) 서버가 자동으로 재실행된다
실행결과
구동이 되는 것을 확인할 수 있다 '프로그래밍 > Python' 카테고리의 다른 글
[Python]_41일차_06.16 (0) 2021.06.17 [오류, 스크랩] Github Sorry, something went wrong. Reload? 오류 해결 방법 (0) 2021.06.08 [python][flask] 파이썬 + 플라스크로 웹서버에서 hello world 출력하기 (0) 2021.01.14 [Python] sqlite3 + python 데이터베이스 연동하기 (0) 2020.12.30 [Python][Error] sqlite3.OperationalError: unable to open database file 오류 해결 (0) 2020.12.30