Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -82,7 +82,7 @@ Important guidelines:
|
|
82 |
3. Always include server_name="0.0.0.0" and server_port=7861 in the launch parameters
|
83 |
4. First requirement must be exactly "gradio==3.32.0"
|
84 |
5. Keep the app simple and focused on the user's request
|
85 |
-
6. DO NOT use any flagging callbacks
|
86 |
7. DO NOT create or use any directories or file paths
|
87 |
8. Do not use features from newer Gradio versions
|
88 |
|
@@ -235,9 +235,24 @@ def run_app(app_code, output_queue):
|
|
235 |
temp_files.append(app_file)
|
236 |
|
237 |
# Make sure the code has the correct launch parameters
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
238 |
if "demo.launch" not in app_code:
|
239 |
-
|
240 |
-
|
|
|
|
|
|
|
|
|
|
|
241 |
|
242 |
# Run the app
|
243 |
output_queue.put(f"Starting the app...\n")
|
@@ -304,7 +319,6 @@ with gr.Blocks(title="Gradio App Generator") as demo:
|
|
304 |
label="Progress Log",
|
305 |
lines=10,
|
306 |
max_lines=20,
|
307 |
-
autoscroll=True,
|
308 |
interactive=False
|
309 |
)
|
310 |
|
@@ -493,5 +507,5 @@ with gr.Blocks(title="Gradio App Generator") as demo:
|
|
493 |
)
|
494 |
|
495 |
if __name__ == "__main__":
|
496 |
-
# Make sure we're not trying to use flagging
|
497 |
-
demo.queue().launch(server_name="0.0.0.0", server_port=7860
|
|
|
82 |
3. Always include server_name="0.0.0.0" and server_port=7861 in the launch parameters
|
83 |
4. First requirement must be exactly "gradio==3.32.0"
|
84 |
5. Keep the app simple and focused on the user's request
|
85 |
+
6. DO NOT use any flagging callbacks or flagging_dir parameters in launch
|
86 |
7. DO NOT create or use any directories or file paths
|
87 |
8. Do not use features from newer Gradio versions
|
88 |
|
|
|
235 |
temp_files.append(app_file)
|
236 |
|
237 |
# Make sure the code has the correct launch parameters
|
238 |
+
with open(app_file, 'r') as f:
|
239 |
+
app_code = f.read()
|
240 |
+
|
241 |
+
# Remove flagging_callback if present
|
242 |
+
app_code = re.sub(r'flagging_callback\s*=\s*[^,)]+', '', app_code)
|
243 |
+
|
244 |
+
# Remove flagging_dir if present
|
245 |
+
app_code = re.sub(r'flagging_dir\s*=\s*[^,)]+', '', app_code)
|
246 |
+
|
247 |
+
# Make sure it has the correct launch parameters
|
248 |
if "demo.launch" not in app_code:
|
249 |
+
app_code += "\n\ndemo.launch(server_name='0.0.0.0', server_port=7861)\n"
|
250 |
+
elif "server_name" not in app_code or "server_port" not in app_code:
|
251 |
+
app_code = re.sub(r'demo\.launch\s*\(', r'demo.launch(server_name="0.0.0.0", server_port=7861, ', app_code)
|
252 |
+
|
253 |
+
# Write the updated code back to the file
|
254 |
+
with open(app_file, 'w') as f:
|
255 |
+
f.write(app_code)
|
256 |
|
257 |
# Run the app
|
258 |
output_queue.put(f"Starting the app...\n")
|
|
|
319 |
label="Progress Log",
|
320 |
lines=10,
|
321 |
max_lines=20,
|
|
|
322 |
interactive=False
|
323 |
)
|
324 |
|
|
|
507 |
)
|
508 |
|
509 |
if __name__ == "__main__":
|
510 |
+
# Make sure we're not trying to use flagging - for Gradio 3.50.2 compatibility
|
511 |
+
demo.queue().launch(server_name="0.0.0.0", server_port=7860)
|