๋ณธ๋ฌธ ๋ฐ”๋กœ๊ฐ€๊ธฐ
๐Ÿ‘จ๐Ÿผ‍๐Ÿ’ป๊ฐœ๋ฐœ/ํŒŒ์ด์ฌ

Flask - static ํŒŒ์ผ๋“ค ์ œ๊ณตํ•˜๊ธฐ

by Janger 2021. 12. 8.
728x90
๋ฐ˜์‘ํ˜•
from flask import Flask, request, send_from_directory

# set the project root directory as the static folder, you can set others.
app = Flask(__name__, static_url_path='')

@app.route('/js/<path:path>')
def send_js(path):
    return send_from_directory('js', path)

if __name__ == "__main__":
    app.run()

 

์ถœ์ฒ˜: 

https://stackoverflow.com/questions/20646822/how-to-serve-static-files-in-flask

 

How to serve static files in Flask

So this is embarrassing. I've got an application that I threw together in Flask and for now it is just serving up a single static HTML page with some links to CSS and JS. And I can't find where in ...

stackoverflow.com

 

728x90
๋ฐ˜์‘ํ˜•