Spaces:
Sleeping
Sleeping
Update main.py
Browse files
main.py
CHANGED
@@ -142,20 +142,23 @@ def generate_script():
|
|
142 |
file.write(modified_cs)
|
143 |
|
144 |
# Step 10: Compile the C# script using mcs
|
145 |
-
compile_command =
|
|
|
|
|
|
|
146 |
|
147 |
# Run the compilation command
|
148 |
try:
|
149 |
-
subprocess.run(compile_command,
|
150 |
except subprocess.CalledProcessError as e:
|
151 |
return f"Compilation failed: {e}", 500
|
|
|
|
|
152 |
|
153 |
# Provide a link to download the compiled executable
|
154 |
return send_file('run.exe', as_attachment=True)
|
155 |
|
156 |
|
157 |
-
|
158 |
-
|
159 |
# Start the Flask app
|
160 |
if __name__ == '__main__':
|
161 |
app.run(host='0.0.0.0', port=7860, debug=True)
|
|
|
142 |
file.write(modified_cs)
|
143 |
|
144 |
# Step 10: Compile the C# script using mcs
|
145 |
+
compile_command = [
|
146 |
+
'mcs', '-target:exe', '-out:run.exe', script_path,
|
147 |
+
'-win32icon:app.ico', '-win32manifest:app.manifest'
|
148 |
+
]
|
149 |
|
150 |
# Run the compilation command
|
151 |
try:
|
152 |
+
subprocess.run(compile_command, check=True)
|
153 |
except subprocess.CalledProcessError as e:
|
154 |
return f"Compilation failed: {e}", 500
|
155 |
+
except FileNotFoundError:
|
156 |
+
return "Compiler 'mcs' not found. Make sure it is installed and in the PATH.", 500
|
157 |
|
158 |
# Provide a link to download the compiled executable
|
159 |
return send_file('run.exe', as_attachment=True)
|
160 |
|
161 |
|
|
|
|
|
162 |
# Start the Flask app
|
163 |
if __name__ == '__main__':
|
164 |
app.run(host='0.0.0.0', port=7860, debug=True)
|