sigyllly commited on
Commit
adbe5cd
·
verified ·
1 Parent(s): b1f0958

Update main.py

Browse files
Files changed (1) hide show
  1. main.py +25 -3
main.py CHANGED
@@ -1,4 +1,4 @@
1
- from flask import Flask, request, send_file, render_template
2
  import os
3
  import subprocess
4
 
@@ -6,9 +6,31 @@ app = Flask(__name__)
6
  UPLOAD_FOLDER = 'uploads'
7
  app.config['UPLOAD_FOLDER'] = UPLOAD_FOLDER
8
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
9
  @app.route('/')
10
  def index():
11
- return render_template('index.html')
12
 
13
  @app.route('/upload', methods=['POST'])
14
  def upload_files():
@@ -57,7 +79,7 @@ def upload_files():
57
  # Compile the NSIS script
58
  try:
59
  result = subprocess.run(['makensis', nsi_path], check=True, capture_output=True, text=True)
60
- return "Compilation successful! Download here: <a href='/download/output.exe'>output.exe</a>", 200
61
  except subprocess.CalledProcessError as e:
62
  return f"Compilation failed: {e.stderr}", 400
63
 
 
1
+ from flask import Flask, request, send_file, render_template_string
2
  import os
3
  import subprocess
4
 
 
6
  UPLOAD_FOLDER = 'uploads'
7
  app.config['UPLOAD_FOLDER'] = UPLOAD_FOLDER
8
 
9
+ # HTML template for the index page
10
+ HTML_TEMPLATE = """
11
+ <!DOCTYPE html>
12
+ <html lang="en">
13
+ <head>
14
+ <meta charset="UTF-8">
15
+ <meta name="viewport" content="width=device-width, initial-scale=1.0">
16
+ <title>NSIS Installer Creator</title>
17
+ </head>
18
+ <body>
19
+ <h1>Upload Files to Create NSIS Installer</h1>
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>
28
+ </html>
29
+ """
30
+
31
  @app.route('/')
32
  def index():
33
+ return render_template_string(HTML_TEMPLATE)
34
 
35
  @app.route('/upload', methods=['POST'])
36
  def upload_files():
 
79
  # Compile the NSIS script
80
  try:
81
  result = subprocess.run(['makensis', nsi_path], check=True, capture_output=True, text=True)
82
+ return f"Compilation successful! Download here: <a href='/download/output.exe'>output.exe</a>", 200
83
  except subprocess.CalledProcessError as e:
84
  return f"Compilation failed: {e.stderr}", 400
85