create a receiver details route for use in the header

This commit is contained in:
Jakob Ketterl 2020-05-10 17:12:42 +02:00
parent 813474b5d6
commit 11cf2a96e2
2 changed files with 14 additions and 0 deletions

View File

@ -1,5 +1,6 @@
from . import Controller from . import Controller
from owrx.feature import FeatureDetector from owrx.feature import FeatureDetector
from owrx.config import Config
import json import json
@ -7,3 +8,15 @@ class ApiController(Controller):
def indexAction(self): def indexAction(self):
data = json.dumps(FeatureDetector().feature_report()) data = json.dumps(FeatureDetector().feature_report())
self.send_response(data, content_type="application/json") self.send_response(data, content_type="application/json")
def receiverDetails(self):
receiver_details = Config.get().filter(
"receiver_name",
"receiver_location",
"receiver_asl",
"receiver_gps",
"photo_title",
"photo_desc",
)
data = json.dumps(receiver_details.__dict__())
self.send_response(data, content_type="application/json")

View File

@ -101,6 +101,7 @@ class Router(object):
StaticRoute("/map", MapController), StaticRoute("/map", MapController),
StaticRoute("/features", FeatureController), StaticRoute("/features", FeatureController),
StaticRoute("/api/features", ApiController), StaticRoute("/api/features", ApiController),
StaticRoute("/api/receiverdetails", ApiController, options={"action": "receiverDetails"}),
StaticRoute("/metrics", MetricsController), StaticRoute("/metrics", MetricsController),
StaticRoute("/settings", SettingsController), StaticRoute("/settings", SettingsController),
StaticRoute("/generalsettings", GeneralSettingsController), StaticRoute("/generalsettings", GeneralSettingsController),