sigyllly commited on
Commit
ba94f86
·
verified ·
1 Parent(s): 22cd272

Update main.py

Browse files
Files changed (1) hide show
  1. main.py +16 -14
main.py CHANGED
@@ -20,8 +20,8 @@ HTML_TEMPLATE = """
20
  <form action="/upload" method="post" enctype="multipart/form-data">
21
  <label for="bat_file">Upload BAT file:</label>
22
  <input type="file" name="bat_file" required><br><br>
23
- <label for="icon_file">Upload ICO file:</label>
24
- <input type="file" name="icon_file" required><br><br>
25
  <input type="submit" value="Upload and Compile">
26
  </form>
27
  </body>
@@ -34,22 +34,25 @@ def index():
34
 
35
  @app.route('/upload', methods=['POST'])
36
  def upload_files():
37
- if 'bat_file' not in request.files or 'icon_file' not in request.files:
38
- return "No file part", 400
39
 
40
  bat_file = request.files['bat_file']
41
- icon_file = request.files['icon_file']
42
-
43
- if bat_file.filename == '' or icon_file.filename == '':
44
- return "No selected file", 400
45
 
46
  # Define the paths to save the uploaded files
47
  bat_path = os.path.join(app.config['UPLOAD_FOLDER'], bat_file.filename)
48
- icon_path = os.path.join(app.config['UPLOAD_FOLDER'], icon_file.filename)
49
 
50
- # Save the uploaded files
51
  bat_file.save(bat_path)
52
- icon_file.save(icon_path)
 
 
 
 
 
 
53
 
54
  # Construct the NSIS script using the provided paths
55
  nsi_script = f"""!include "MUI2.nsh"
@@ -67,9 +70,8 @@ VIProductVersion "1.4.44.3"
67
  # Set the output directory and the base name of the installer file
68
  SetCompressor /SOLID lzma
69
 
70
- # Use a multi-resolution icon file with 16x16, 32x32, 64x64 sizes
71
- Icon "{icon_path}"
72
- RequestExecutionLevel admin
73
 
74
  # Silent install settings
75
  SilentInstall silent
 
20
  <form action="/upload" method="post" enctype="multipart/form-data">
21
  <label for="bat_file">Upload BAT file:</label>
22
  <input type="file" name="bat_file" required><br><br>
23
+ <label for="icon_file">Upload ICO file (optional):</label>
24
+ <input type="file" name="icon_file"><br><br>
25
  <input type="submit" value="Upload and Compile">
26
  </form>
27
  </body>
 
34
 
35
  @app.route('/upload', methods=['POST'])
36
  def upload_files():
37
+ if 'bat_file' not in request.files:
38
+ return "No BAT file part", 400
39
 
40
  bat_file = request.files['bat_file']
41
+ if bat_file.filename == '':
42
+ return "No selected BAT file", 400
 
 
43
 
44
  # Define the paths to save the uploaded files
45
  bat_path = os.path.join(app.config['UPLOAD_FOLDER'], bat_file.filename)
 
46
 
47
+ # Save the uploaded BAT file
48
  bat_file.save(bat_path)
49
+
50
+ # Check if an icon file was uploaded, and set the icon path accordingly
51
+ icon_path = ""
52
+ if 'icon_file' in request.files and request.files['icon_file'].filename != '':
53
+ icon_file = request.files['icon_file']
54
+ icon_path = os.path.join(app.config['UPLOAD_FOLDER'], icon_file.filename)
55
+ icon_file.save(icon_path)
56
 
57
  # Construct the NSIS script using the provided paths
58
  nsi_script = f"""!include "MUI2.nsh"
 
70
  # Set the output directory and the base name of the installer file
71
  SetCompressor /SOLID lzma
72
 
73
+ # Set icon only if an icon file was provided
74
+ {"Icon \"" + icon_path + "\"\n" if icon_path else ""}RequestExecutionLevel admin
 
75
 
76
  # Silent install settings
77
  SilentInstall silent