Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

206
Vistas
Triggering a python function when tab closes with flask

I'm trying to create a modern looking GUI so I decided to setup a simple flask app. Eventually, I want to pack the app up in a .exe file, so I want to start the server and open a web-browser when I start the flask app, and quit the server when I close the tab. My question is:

Is there any way to trigger a python function that quits the flask server when I close the tab?

Thank you for the help in advance!

about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

You can add an event listener to beforeunload event and send a request when the tab is about to close.

window.onbeforeunload = () => fetch('/stop');

When you confirm it, the request is sent, and you can shut down the server inside the handler.

The only downside is that the browser shows a popup, confirming if you really want to leave.

about 4 years ago · Juan Pablo Isaza Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda