commit ed2b4a773c90f1ac6f2887651af46658a06a3f1d Author: gz Date: Fri May 29 09:40:08 2026 +0800 Initial commit diff --git a/templates/index.html b/templates/index.html new file mode 100644 index 0000000..08f0033 --- /dev/null +++ b/templates/index.html @@ -0,0 +1,211 @@ + + + + + + 缅邈岁月 + + + + + + + + + + + + + diff --git a/templates/index.html_20250411 b/templates/index.html_20250411 new file mode 100644 index 0000000..ef3d1f3 --- /dev/null +++ b/templates/index.html_20250411 @@ -0,0 +1,174 @@ + + + + + + ttings + + + + + + + + + + + + + diff --git a/templates/index.html_20250413 b/templates/index.html_20250413 new file mode 100644 index 0000000..3a242d3 --- /dev/null +++ b/templates/index.html_20250413 @@ -0,0 +1,196 @@ + + + + + + Optimized Media Gallery + + + + + + + + + + + + + diff --git a/ttings.py b/ttings.py new file mode 100644 index 0000000..5adf760 --- /dev/null +++ b/ttings.py @@ -0,0 +1,39 @@ +from flask import Flask, send_from_directory, render_template, jsonify +import os + +app = Flask(__name__) + +# 静态文件主目录 +#loc +#STATIC_DIR = "/Users/zgz/Documents/images/share/bak" +#server +STATIC_DIR = "/mnt/ttings" + +# 支持的文件类型 +IMAGE_EXTENSIONS = {".jpg", ".jpeg", ".png", ".gif", ".JPG", ".JPEG", ".PNG", ".GIF"} +VIDEO_EXTENSIONS = {".mp4", ".avi", ".mov", ".wmv", ".m4v", ".mpg"} + +# 递归获取目录中的所有文件 +def get_files(directory): + files = [] + for root, _, filenames in os.walk(directory): + for filename in filenames: + ext = os.path.splitext(filename)[1].lower() + if ext in IMAGE_EXTENSIONS or ext in VIDEO_EXTENSIONS: + relative_path = os.path.relpath(os.path.join(root, filename), STATIC_DIR) + files.append(relative_path) + return files + +@app.route('/') +def index(): + files = get_files(STATIC_DIR) + return render_template('index.html', files=files) + +@app.route('/media/') +def media(filename): + # 返回静态文件(支持子目录) + return send_from_directory(STATIC_DIR, filename) + + +if __name__ == '__main__': + app.run(host='0.0.0.0', port=8177) diff --git a/uwsgi.ini b/uwsgi.ini new file mode 100644 index 0000000..e4043ae --- /dev/null +++ b/uwsgi.ini @@ -0,0 +1,30 @@ +[uwsgi] +uid = uwsgi +gid = uwsgi + +# 启动服务监听的地址和端口 +http-socket = 0.0.0.0:8177 + +# 指定虚拟环境路径 +virtualenv = /opt/service/python_prj/pictoHub.env + +# 指定 Flask 应用文件的路径 +wsgi-file = /opt/service/python_prj/ttingsHub/ttings.py + +# 设置 Flask 的应用实例 +callable = app + +# 设置静态文件目录映射 +static-map = /static=/opt/service/python_prj/ttingsHub/static/ + +# 日志文件 +logto = /var/log/uwsgi/uwsgi.log + +# 设置进程数 +processes = 4 + +# 启动时的 Python 环境路径 +home = /opt/service/python_prj/pictoHub.env + +# 确保应用正常启动 +touch-reload = /opt/service/python_prj/ttingsHub/ttings.py