from flask import Flask, request, send_from_directory, render_template_string import os import subprocess app = Flask(__name__) # Directory to save uploaded ISS 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 = """
{{ logs }}""" @app.route('/') def index(): return render_template_string(html_template, logs="") @app.route('/upload', methods=['POST']) def upload_iss(): if 'iss_file' not in request.files: return "No file part" file = request.files['iss_file'] if file.filename == '': return "No selected file" # Save the ISS file iss_path = os.path.join(UPLOAD_FOLDER, file.filename) file.save(iss_path) # Compile the ISS file using Inno Setup exe_name = file.filename.replace('.iss', '.exe') exe_path = os.path.join(COMPILE_FOLDER, exe_name) # Command to run Inno Setup compile_command = f'inno-setup-compiler "{iss_path}"' # Run the command and capture logs result = subprocess.run(compile_command, shell=True, capture_output=True, text=True) logs = result.stdout + result.stderr if result.returncode == 0: return f'Compilation successful! Download here' else: return f'Compilation failed:
{logs}' @app.route('/download/