Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

321
Views
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 answers
Answer question

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 Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!