gps-sdr-sim/mapserver/mapper.py

49 lines
929 B
Python
Raw Normal View History

#!/usr/bin/env python
from __future__ import print_function
2017-04-30 23:40:24 +08:00
import socket
import struct
import time
import web
2020-12-12 23:23:21 +08:00
HOST = 'localhost'
PORT = 5678
BUFFSIZE = 1024
ADDR = (HOST, PORT)
2020-12-12 23:23:21 +08:00
sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
urls = (
'/', 'index',
'/post', 'post',
'/static/*', 'static',
)
app = web.application(urls, globals())
class index:
def GET(self):
raise web.seeother('/static/baidumap.html')
class post:
def POST(self):
inn = web.input()
lon = float(inn.get('lon'))
lat = float(inn.get('lat'))
h = float(inn.get('hgt'))
data = struct.pack('ddd', lat, lon, h)
sock.sendto(data, ADDR)
print(lon, lat, h)
class static:
def GET(self, media, file):
try:
f = open(media + '/' + file, 'r')
return f.read()
except:
return '404'
2020-12-12 23:23:21 +08:00
if __name__ == '__main__':
app.run()