19 lines
516 B
Python
19 lines
516 B
Python
import os
|
|
from flask import Blueprint, redirect, url_for, current_app, send_file, abort
|
|
|
|
bp = Blueprint("main", __name__)
|
|
|
|
@bp.route("/")
|
|
def index():
|
|
return redirect(url_for("feed.discover"))
|
|
|
|
@bp.route("/uploads/<path:filename>")
|
|
def uploads(filename):
|
|
root = os.path.abspath(current_app.config["UPLOAD_FOLDER"])
|
|
path = filename
|
|
if not os.path.isabs(path):
|
|
path = os.path.abspath(os.path.join(root, filename))
|
|
if not path.startswith(root):
|
|
abort(404)
|
|
return send_file(path)
|