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

319
Vistas
unable to use getCurrentPosition() in a Flask local host app

I'm working on a python flask app for practice. I want to access the getCurrentPosition() of JS to get the geolocation. However, as the app is running on http://localhost:5000/ I'm getting an error that getCurrentPosition() and watchPosition() are deprecated on insecure origins.

Is there a way that it will work on the flask localhost server?

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

0

I have found the resolution. Geolocation can only be used in HTTPS requests. In order to convert your localhost flask app to HTTPS from HTTP, you have to use OpenSSL to create a key and certificate.

Follow the below step to set up your HTTPS environment for the flask localhost server

  • If you have installed Git then OpenSSL command comes in a package. Open git bash where you want to store the files.
  • Run the below command in Git Bash.

openssl req -newkey rsa:2048 -nodes -keyout key.pem -x509 -days 365 -out certificate.pem

  • Change your app.run() method in python script to below
context = (r"{path}\certificate.pem", r"{path}\key.pem")
if __name__ == '__main__':
    app.run(host='0.0.0.0',port=5000,debug=True,ssl_context=context)

path refers to the location directory where the key and certificate files are stored.

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