flask make static directory
from flask import Flask, send_from_directory
app = Flask(__name__)
@app.route("/static/<path:path>")
def static_dir(path):
return send_from_directory("static", path)
if __name__ == "__main__":
app.run()
flask make static directory
from flask import Flask, send_from_directory
app = Flask(__name__)
@app.route("/static/<path:path>")
def static_dir(path):
return send_from_directory("static", path)
if __name__ == "__main__":
app.run()
how to send image to template thats not in static flask
from config import directory_to_image_folder
#first create the route
@app.route('/uploads/<path:filename>')
def download_file(filename):
return send_from_directory(directory_to_image_folder, filename, as_attachment=True)
#add this to the template inside of an image tag
<img width="100%" height="100%" src="{{ url_for('download_file', filename='name_of_image.extension') }}">
My flask static first file
Hello This is static file
Copyright © 2021 Codeinu
Forgot your account's password or having trouble logging into your Account? Don't worry, we'll help you to get back your account. Enter your email address and we'll send you a recovery link to reset your password. If you are experiencing problems resetting your password contact us