Spaces:
Sleeping
Sleeping
Update main.py
Browse files
main.py
CHANGED
@@ -154,18 +154,21 @@ def generate_script():
|
|
154 |
with open(project_file_path, 'w') as file:
|
155 |
file.write(project_file_content)
|
156 |
|
157 |
-
#
|
158 |
compile_command = f'dotnet build {project_name}/{project_name}.csproj -c Release -o /app'
|
159 |
-
result = subprocess.run(compile_command, shell=True, check=
|
160 |
|
161 |
-
#
|
162 |
if result.returncode != 0:
|
163 |
-
|
|
|
|
|
164 |
|
165 |
# Provide a link to download the compiled executable
|
166 |
exe_path = os.path.join('/app', project_name, 'bin', 'Release', 'net7.0', 'PolymorphicProgram.exe')
|
167 |
return send_file(exe_path, as_attachment=True)
|
168 |
|
|
|
169 |
# Start the Flask app
|
170 |
if __name__ == '__main__':
|
171 |
app.run(host='0.0.0.0', port=7860, debug=True)
|
|
|
154 |
with open(project_file_path, 'w') as file:
|
155 |
file.write(project_file_content)
|
156 |
|
157 |
+
# Compile the C# project using dotnet build
|
158 |
compile_command = f'dotnet build {project_name}/{project_name}.csproj -c Release -o /app'
|
159 |
+
result = subprocess.run(compile_command, shell=True, check=True, capture_output=True)
|
160 |
|
161 |
+
# Log the output of the compilation command for debugging
|
162 |
if result.returncode != 0:
|
163 |
+
error_message = result.stderr.decode() if result.stderr else "Unknown error"
|
164 |
+
print(f"Compilation failed: {error_message}")
|
165 |
+
return f"Compilation failed: {error_message}", 500
|
166 |
|
167 |
# Provide a link to download the compiled executable
|
168 |
exe_path = os.path.join('/app', project_name, 'bin', 'Release', 'net7.0', 'PolymorphicProgram.exe')
|
169 |
return send_file(exe_path, as_attachment=True)
|
170 |
|
171 |
+
|
172 |
# Start the Flask app
|
173 |
if __name__ == '__main__':
|
174 |
app.run(host='0.0.0.0', port=7860, debug=True)
|