Commit 28858b9e authored by Jonathan Krebs's avatar Jonathan Krebs
Browse files

Initial commit

parents
import datetime
from flask import Flask, request, send_from_directory, render_template
app = Flask(__name__)
@app.route("/")
def hello():
return render_template("index.html")
@app.route("/set", methods=["POST"])
def setpos():
data = request.get_json()
print(data)
time = datetime.datetime.fromtimestamp(data["t"]/1000)
time = time.strftime("%H:%M:%S") + ".%.2d" % round(time.microsecond/10000)
b = "%.2d%6.2f,%s" % (int(data["lat"]))
print("$GPGGA,%s,BBBB.BBBB,b,LLLLL.LLLL,l,Q,NN,D.D,H.H,h,G.G,g,A.A,RRRR*PP" % (time))
return "a"
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
</head>
<body>
<div id="demo"></div>
<script>
var x = document.getElementById("demo");
function getLocation() {
x.innerHTML="searching";
if (navigator.geolocation) {
} else {
x.innerHTML = "Geolocation is not supported by this browser.";
}
}
function showPosition(position) {
var j;
x.innerHTML = j = JSON.stringify({"lon": position.coords.longitude, "lat": position.coords.latitude, "acc": position.coords.accuracy, "t": position.timestamp});
var oReq = new XMLHttpRequest();
oReq.open("POST", "{{ url_for("setpos")}}" );
oReq.setRequestHeader('Content-type', 'application/json');
oReq.send(j);
}
var options = {
enableHighAccuracy: true,
timeout: 1000,
maximumAge: 0
};
handle = null;
function start(){
if(handle === null){
handle = navigator.geolocation.watchPosition(showPosition, console.error, options);
}
}
function stop(){
window.clearInterval(handle);
handle = null;
}
</script>
<button onclick="start()" >Start</button>
<button onclick="stop()" >Stop</button>
</body>
</html>
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment