Spaces:
Sleeping
Sleeping
Update app.py
Browse files12345678910111213141516import subprocessimport sysimport threadingdef run_training():print("Starting training job...")subprocess.run([sys.executable, "training.py"], check=True)print("Training finished.")thread = threading.Thread(target=run_training)thread.start()import gradio as grdef status():return "Training running…"gr.Interface(fn=status, inputs=[], outputs="text").launch()123456789101112131415161718192021222324import subprocessimport sysimport threadingfrom http.server import HTTPServer, BaseHTTPRequestHandlerdef run_training():print("Starting training job...")subprocess.run([sys.executable, "training.py"], check=True)print("Training finished.")# Start training in backgroundthreading.Thread(target=run_training).start()# Minimal HTTP server to keep the container alive (port 7860)class Handler(BaseHTTPRequestHandler):def do_GET(self):self.send_response(200)self.end_headers()self.wfile.write(b"Training in progress...")def do_POST(self):self.do_GET()print("Keeping container alive on port 7860")HTTPServer(("0.0.0.0", 7860), Handler).serve_forever()
app.py+14-6