File size: 2,103 Bytes
45a1acf
 
 
66f8fc1
45a1acf
66f8fc1
872f6da
45a1acf
 
66f8fc1
45a1acf
 
66f8fc1
45a1acf
 
 
 
 
 
 
872f6da
45a1acf
 
872f6da
45a1acf
872f6da
45a1acf
 
 
 
 
66f8fc1
45a1acf
 
872f6da
66f8fc1
45a1acf
872f6da
 
45a1acf
 
872f6da
45a1acf
 
 
 
872f6da
 
 
45a1acf
872f6da
 
45a1acf
 
872f6da
 
45a1acf
872f6da
 
 
 
45a1acf
 
872f6da
45a1acf
872f6da
329f9c0
45a1acf
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
from flask import Flask, request, send_from_directory, render_template_string
import os
import subprocess

app = Flask(__name__)

# Directory to save uploaded NSI files and generated EXEs
UPLOAD_FOLDER = 'uploads'
COMPILE_FOLDER = 'compiled'

os.makedirs(UPLOAD_FOLDER, exist_ok=True)
os.makedirs(COMPILE_FOLDER, exist_ok=True)

# HTML template for the interface
html_template = """
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>NSIS Compiler</title>
</head>
<body>
    <h1>Upload your .nsi file to compile</h1>
    <form action="/upload" method="post" enctype="multipart/form-data">
        <input type="file" name="nsi_file" accept=".nsi" required>
        <button type="submit">Upload and Compile</button>
    </form>
</body>
</html>
"""

@app.route('/')
def index():
    return render_template_string(html_template)

@app.route('/upload', methods=['POST'])
def upload_nsi():
    if 'nsi_file' not in request.files:
        return "No file part"
    
    file = request.files['nsi_file']
    
    if file.filename == '':
        return "No selected file"
    
    # Save the NSI file
    nsi_path = os.path.join(UPLOAD_FOLDER, file.filename)
    file.save(nsi_path)
    
    # Compile the NSI file using makensis
    exe_name = file.filename.replace('.nsi', '.exe')
    exe_path = os.path.join(COMPILE_FOLDER, exe_name)
    
    # Command to run NSIS compiler
    compile_command = f'makensis {nsi_path}'
    
    result = subprocess.run(compile_command, shell=True, capture_output=True)

    # Log output
    output = result.stdout.decode() + '\n' + result.stderr.decode()
    
    if result.returncode == 0:
        return f'Compilation successful! Download <a href="/download/{exe_name}">here</a><br><pre>{output}</pre>'
    else:
        return f'Compilation failed: <pre>{output}</pre>'

@app.route('/download/<filename>')
def download_file(filename):
    return send_from_directory(COMPILE_FOLDER, filename)

if __name__ == '__main__':
    app.run(host='0.0.0.0', port=7860, debug=True)