Serve images from a separate direcory configured in an external config
file (config.py)
This commit is contained in:
parent
d45d1347bd
commit
f0fb5f0d9f
4 changed files with 11 additions and 1 deletions
|
@ -1,8 +1,10 @@
|
|||
#!/usr/bin/python3
|
||||
|
||||
from flask import Flask, render_template
|
||||
from flask import Flask, render_template, send_from_directory
|
||||
from random import randint
|
||||
|
||||
import config
|
||||
|
||||
app = Flask(__name__)
|
||||
|
||||
|
||||
|
@ -11,5 +13,10 @@ def hello():
|
|||
return render_template("hello.html", num=randint(1, 23))
|
||||
|
||||
|
||||
@app.route("/img/<path:filename>")
|
||||
def image(filename):
|
||||
return send_from_directory(config.imgdir, filename)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
app.run()
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue