Spaces:
Sleeping
Sleeping
Update main.py
Browse files
main.py
CHANGED
@@ -107,7 +107,7 @@ def index():
|
|
107 |
|
108 |
@app.route('/generate', methods=['POST'])
|
109 |
def generate_script():
|
110 |
-
#
|
111 |
assembly_info = {
|
112 |
'title': random.choice(titles),
|
113 |
'description': random.choice(descriptions),
|
@@ -121,7 +121,7 @@ def generate_script():
|
|
121 |
'informational_version': random_version()
|
122 |
}
|
123 |
|
124 |
-
#
|
125 |
modified_cs = base_cs_template.replace('<<title>>', assembly_info['title']) \
|
126 |
.replace('<<description>>', assembly_info['description']) \
|
127 |
.replace('<<configuration>>', assembly_info['configuration']) \
|
@@ -141,12 +141,12 @@ def generate_script():
|
|
141 |
with open(script_path, 'w') as file:
|
142 |
file.write(modified_cs)
|
143 |
|
144 |
-
#
|
145 |
compile_command = [
|
146 |
-
'mcs', '-target:
|
147 |
'-win32icon:app.ico', '-win32manifest:app.manifest'
|
148 |
]
|
149 |
-
|
150 |
# Run the compilation command
|
151 |
try:
|
152 |
subprocess.run(compile_command, check=True)
|
@@ -159,6 +159,7 @@ def generate_script():
|
|
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)
|
|
|
107 |
|
108 |
@app.route('/generate', methods=['POST'])
|
109 |
def generate_script():
|
110 |
+
# Generate the randomized assembly information using meaningful words
|
111 |
assembly_info = {
|
112 |
'title': random.choice(titles),
|
113 |
'description': random.choice(descriptions),
|
|
|
121 |
'informational_version': random_version()
|
122 |
}
|
123 |
|
124 |
+
# Replace placeholders in the base template
|
125 |
modified_cs = base_cs_template.replace('<<title>>', assembly_info['title']) \
|
126 |
.replace('<<description>>', assembly_info['description']) \
|
127 |
.replace('<<configuration>>', assembly_info['configuration']) \
|
|
|
141 |
with open(script_path, 'w') as file:
|
142 |
file.write(modified_cs)
|
143 |
|
144 |
+
# Compile the C# script using mcs
|
145 |
compile_command = [
|
146 |
+
'mcs', '-target:winexe', '-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)
|
|
|
159 |
return send_file('run.exe', as_attachment=True)
|
160 |
|
161 |
|
162 |
+
|
163 |
# Start the Flask app
|
164 |
if __name__ == '__main__':
|
165 |
app.run(host='0.0.0.0', port=7860, debug=True)
|