Python/Flask Server7 Flask에 CSS 파일 포함하기 <link rel="stylesheet" href="{{ url_for('static', filename='폴더명/파일명.css') }}"> css 적용을 위해선 html파일을 랜더링한것 처럼 파일을 불러와야함 css파일은 static file이므로 이를 랜더링하려면 ========================================================================================= from flask import Flask, render_template app = Flask(__name__) @app.route("/") def main(): return render_template('main.html') if __name_ _ == " __main__ " : app.run () ====================================================================.. 2022. 7. 16. Flask에 html파일 불러오기 (render_template) 랜더딩 함수로 외부에서 작성된 html을 받아올 수 있음!!! from flask import Flask, render_template app = Flask (_ _name_ _) @app.route("/") def function_name() : return render_template('파일명.html') if _ _name_ _ == " _ _main_ _ " : app.run () 2022. 7. 16. Flask 라이브러리 기본 사용법 [ @app.route / request.method / return / ] from flask import Flask from flask import request, redirect , render_template app = Flask (__name__) @app.route("/urlmapping", method = ['get', 'post']) def function_name() : if request.method == 'post' #.......(실행로직)............. return render_template('파일명.html') else: #.......(실행로직)............. return render_template('파일명.html') if __name__ == " __main__ " : app.run ( host = "ip주소", port =.. 2022. 7. 16. 이전 1 2 다음