add aprs symbols to http server
This commit is contained in:
parent
30512e347a
commit
c6c4012a36
@ -281,3 +281,6 @@ aprs_igate_server = "euro.aprs2.net"
|
|||||||
aprs_igate_password = ""
|
aprs_igate_password = ""
|
||||||
# beacon uses the receiver_gps setting, so if you enable this, make sure the location is correct there
|
# beacon uses the receiver_gps setting, so if you enable this, make sure the location is correct there
|
||||||
aprs_igate_beacon = False
|
aprs_igate_beacon = False
|
||||||
|
|
||||||
|
# path to the aprs symbols repository (get it here: https://github.com/hessu/aprs-symbols)
|
||||||
|
aprs_symbols_path = "/opt/aprs-symbols/png"
|
||||||
|
@ -55,9 +55,15 @@ class StatusController(Controller):
|
|||||||
|
|
||||||
|
|
||||||
class AssetsController(Controller):
|
class AssetsController(Controller):
|
||||||
|
def __init__(self, handler, request, path):
|
||||||
|
if not path.endswith("/"):
|
||||||
|
path += "/"
|
||||||
|
self.path = path
|
||||||
|
super().__init__(handler, request)
|
||||||
|
|
||||||
def serve_file(self, file, content_type=None):
|
def serve_file(self, file, content_type=None):
|
||||||
try:
|
try:
|
||||||
modified = datetime.fromtimestamp(os.path.getmtime("htdocs/" + file))
|
modified = datetime.fromtimestamp(os.path.getmtime(self.path + file))
|
||||||
|
|
||||||
if "If-Modified-Since" in self.handler.headers:
|
if "If-Modified-Since" in self.handler.headers:
|
||||||
client_modified = datetime.strptime(
|
client_modified = datetime.strptime(
|
||||||
@ -67,7 +73,7 @@ class AssetsController(Controller):
|
|||||||
self.send_response("", code=304)
|
self.send_response("", code=304)
|
||||||
return
|
return
|
||||||
|
|
||||||
f = open("htdocs/" + file, "rb")
|
f = open(self.path + file, "rb")
|
||||||
data = f.read()
|
data = f.read()
|
||||||
f.close()
|
f.close()
|
||||||
|
|
||||||
@ -82,6 +88,17 @@ class AssetsController(Controller):
|
|||||||
self.serve_file(filename)
|
self.serve_file(filename)
|
||||||
|
|
||||||
|
|
||||||
|
class OwrxAssetsController(AssetsController):
|
||||||
|
def __init__(self, handler, request):
|
||||||
|
super().__init__(handler, request, "htdocs/")
|
||||||
|
|
||||||
|
|
||||||
|
class AprsSymbolsController(AssetsController):
|
||||||
|
def __init__(self, handler, request):
|
||||||
|
pm = PropertyManager.getSharedInstance()
|
||||||
|
super().__init__(handler, request, pm["aprs_symbols_path"])
|
||||||
|
|
||||||
|
|
||||||
class TemplateController(Controller):
|
class TemplateController(Controller):
|
||||||
def render_template(self, file, **vars):
|
def render_template(self, file, **vars):
|
||||||
f = open("htdocs/" + file, "r")
|
f = open("htdocs/" + file, "r")
|
||||||
|
10
owrx/http.py
10
owrx/http.py
@ -1,12 +1,13 @@
|
|||||||
from owrx.controllers import (
|
from owrx.controllers import (
|
||||||
StatusController,
|
StatusController,
|
||||||
IndexController,
|
IndexController,
|
||||||
AssetsController,
|
OwrxAssetsController,
|
||||||
WebSocketController,
|
WebSocketController,
|
||||||
MapController,
|
MapController,
|
||||||
FeatureController,
|
FeatureController,
|
||||||
ApiController,
|
ApiController,
|
||||||
MetricsController,
|
MetricsController,
|
||||||
|
AprsSymbolsController,
|
||||||
)
|
)
|
||||||
from http.server import BaseHTTPRequestHandler
|
from http.server import BaseHTTPRequestHandler
|
||||||
import re
|
import re
|
||||||
@ -36,11 +37,12 @@ class Router(object):
|
|||||||
mappings = [
|
mappings = [
|
||||||
{"route": "/", "controller": IndexController},
|
{"route": "/", "controller": IndexController},
|
||||||
{"route": "/status", "controller": StatusController},
|
{"route": "/status", "controller": StatusController},
|
||||||
{"regex": "/static/(.+)", "controller": AssetsController},
|
{"regex": "/static/(.+)", "controller": OwrxAssetsController},
|
||||||
|
{"regex": "/aprs-symbols/(.+)", "controller": AprsSymbolsController},
|
||||||
{"route": "/ws/", "controller": WebSocketController},
|
{"route": "/ws/", "controller": WebSocketController},
|
||||||
{"regex": "(/favicon.ico)", "controller": AssetsController},
|
{"regex": "(/favicon.ico)", "controller": OwrxAssetsController},
|
||||||
# backwards compatibility for the sdr.hu portal
|
# backwards compatibility for the sdr.hu portal
|
||||||
{"regex": "/(gfx/openwebrx-avatar.png)", "controller": AssetsController},
|
{"regex": "/(gfx/openwebrx-avatar.png)", "controller": OwrxAssetsController},
|
||||||
{"route": "/map", "controller": MapController},
|
{"route": "/map", "controller": MapController},
|
||||||
{"route": "/features", "controller": FeatureController},
|
{"route": "/features", "controller": FeatureController},
|
||||||
{"route": "/api/features", "controller": ApiController},
|
{"route": "/api/features", "controller": ApiController},
|
||||||
|
Loading…
Reference in New Issue
Block a user