Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Jonathan Krebs
webgps
Commits
28858b9e
Commit
28858b9e
authored
Aug 09, 2018
by
Jonathan Krebs
Browse files
Initial commit
parents
Changes
2
Hide whitespace changes
Inline
Side-by-side
position.py
0 → 100644
View file @
28858b9e
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"
templates/index.html
0 → 100644
View file @
28858b9e
<!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>
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment