commit e2b14ca7fe2cacbc51e6b3a5e526a5e39680a712 Author: shouchih_chen Date: Sat Jun 21 13:22:28 2025 +0800 First commit diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..e205a6a --- /dev/null +++ b/.gitignore @@ -0,0 +1,5 @@ +__pycache__/* +uploads/* +generated/* +*.pyc +*.pyo diff --git a/_ref/style.png b/_ref/style.png new file mode 100644 index 0000000..fae1894 Binary files /dev/null and b/_ref/style.png differ diff --git a/app.py b/app.py new file mode 100644 index 0000000..4e5b73b --- /dev/null +++ b/app.py @@ -0,0 +1,49 @@ + +import os +import uuid +from flask import Flask, render_template, request, send_file + +app = Flask(__name__) + +UPLOAD_FOLDER = 'uploads' +GENERATED_IMAGES_FOLDER = 'generated_images' +ALLOWED_EXTENSIONS = {'csv'} + +app.config['UPLOAD_FOLDER'] = UPLOAD_FOLDER +app.config['GENERATED_IMAGES_FOLDER'] = GENERATED_IMAGES_FOLDER + +# 確保目錄存在 +os.makedirs(UPLOAD_FOLDER, exist_ok=True) +os.makedirs(GENERATED_IMAGES_FOLDER, exist_ok=True) + +def allowed_file(filename): + return '.' in filename and \ + filename.rsplit('.', 1)[1].lower() in ALLOWED_EXTENSIONS + + +@app.route("/") +def index(): + return render_template("index.html") +@app.route("/hello") +def hello(): + return "Hello, World!" + +@app.route('/upload_csv', methods=['POST']) +def upload_csv(): + print("Received request to upload CSV file") + if 'csvFile' not in request.files: + return "No file part", 400 + file = request.files['csvFile'] + if file.filename == '': + return "No selected file", 400 + if file and allowed_file(file.filename): + unique_filename = str(uuid.uuid4()) + '.csv' + csv_path = os.path.join(app.config['UPLOAD_FOLDER'], unique_filename) + file.save(csv_path) + return "File uploaded successfully", 200 + + +if __name__ == '__main__': + # 當在生產環境部署時,不建議使用 debug=True + # 可以指定 host='0.0.0.0' 讓外部可訪問 (在防火牆允許的情況下) + app.run(debug=True, host='127.0.0.1', port=5000) \ No newline at end of file diff --git a/generate_images.py b/generate_images.py new file mode 100644 index 0000000..ceb8cac --- /dev/null +++ b/generate_images.py @@ -0,0 +1,2 @@ +import sys +from PySide6.QtCore import QCoreApplication, QTimer, QObject, Signal, Slot \ No newline at end of file diff --git a/templates/index.html b/templates/index.html new file mode 100644 index 0000000..cde55a5 --- /dev/null +++ b/templates/index.html @@ -0,0 +1,67 @@ + + + + + + CSV 轉圖片工具 + + +

上傳 CSV 產生圖片

+
+ + +
+
+ + + + + \ No newline at end of file diff --git a/架構圖.drawio b/架構圖.drawio new file mode 100644 index 0000000..c32978c --- /dev/null +++ b/架構圖.drawio @@ -0,0 +1,63 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +