position.py 855 Bytes
Newer Older
Jonathan Krebs's avatar
Jonathan Krebs committed
1
import datetime
2
3
4
5
6
7
8
9
10
11
12
13

from flask import Flask, jsonify, render_template, request, send_from_directory

app = Flask(__name__, static_url_path='/static')

@app.route('/static/<path:path>')
def send_static(path):
    return send_from_directory('static', path)

@app.route('/static/assets/<path:path>')
def send_node_modules(path):
    return send_from_directory('node_modules', path)
Jonathan Krebs's avatar
Jonathan Krebs committed
14
15
16
17
18
19
20
21
22
23
24
25
26

@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))
27
    return jsonify({'success': True})