gps-sdr-sim/mapserver/mapper.py
Chuang Zhu 4ce4d0a753 change back to web.py since it is much more faster
And finally I found that web.py supports Python 3...
2020-12-13 01:16:17 +08:00

49 lines
929 B
Python
Executable File

#!/usr/bin/env python
from __future__ import print_function
import socket
import struct
import time
import web
HOST = 'localhost'
PORT = 5678
BUFFSIZE = 1024
ADDR = (HOST, PORT)
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'
if __name__ == '__main__':
app.run()