INNER CODE UNIT · Python
index
AnsahMohammad/shots-studio · legacy/web/app.py:37
def index():
return render_template("index.html", images=images)
@app.route("/scan", methods=["POST"])
def scan_directory():
global images
data = request.json
directory = data.get("path", os.getcwd())
if not os.path.exists(directory):
return jsonify({"success": False, "error": "Directory does not exist"}), 400
images.clear() # Clear existing images
for root, _, files in os.walk(directory):
for file in files:
if os.path.splitext(file)[1].lower() in ALLOWED_IMAGE_EXTENSIONS: