Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

314
Visualizações
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 Respostas
Responde à pergunta

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 Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda