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 = """ NSIS Compiler

Upload your .nsi file to compile

""" @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 here
{output}
' else: return f'Compilation failed:
{output}
' @app.route('/download/') 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)