So I've been poking around the web for awhile in search of a Python library that returns your exact current location and find that there is nothing available unless you go about the cheapish and inaccurate method of finding your location via your IP Address which I've tested on my mobile hotspot and it is off by 100 miles.
I have another solution to this but it will require mixing JavaScript with Python, and I need help, I've only been on Python/Django for a few days.
Since Python is server-side, I haven't been able to find any libraries that can pinpoint your precise longitude and latitude. However with client-side JavaScript, this is extremely easy and requires no libraries whatsoever:
So I am wondering if there are any Python programmers out there with a little more experience under their belt that could explain here how you can run the javascript code above, and return the javascript output as a Python string:
python
>>>javascriptOutput = runJavaScript("<script> function showPosition(position) </script>")
>>>print javascriptOutput
<p id="long">-122.15563439999998</p> <p id="lat">37.4458668</p>
>>>
So my idea here is to run the entire HTML block in the JSfiddle URL I provided in a single python function that'll return the same result the JSfiddle provides.
With that result I can store it in a python variable and do some string concatination to it to finally store my accurate client side longitude and latitude coordinates.
So is it possible to run some JavaScript in a Python function?
OR
Can you use Python/Django to somehow read the user's HTML source that the user sees after running the javascript/HTML5 geolocation?
The more I think about this now the more I'm starting to think that the Javascript is going to have to AJAX something over to the Django server...