Add theme system for customizable backgrounds
- Move backgrounds to themed folders (backgrounds/desert/, backgrounds/custom/) - Add theme config option in config.json (default: "desert") - Add /api/config endpoint to serve theme and location - Update pixel-view.js to load backgrounds from theme folder - Add config.json.example for reference - Update CONFIG.md documentation Users can now set "theme": "custom" and place their own backgrounds in backgrounds/custom/ to customize the view for their location. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
12
server.py
12
server.py
@@ -24,7 +24,8 @@ config = {
|
||||
"lat": 0.0,
|
||||
"lon": 0.0
|
||||
},
|
||||
"web_port": 2001
|
||||
"web_port": 2001,
|
||||
"theme": "desert"
|
||||
}
|
||||
|
||||
def load_config():
|
||||
@@ -45,6 +46,7 @@ def load_config():
|
||||
print(f" Receiver port: {config['receiver_port']}")
|
||||
print(f" Location: {config['location']['name']} ({config['location']['lat']}, {config['location']['lon']})")
|
||||
print(f" Web port: {config['web_port']}")
|
||||
print(f" Theme: {config.get('theme', 'desert')}")
|
||||
|
||||
# Flight data storage
|
||||
flights: Dict[str, dict] = {}
|
||||
@@ -302,6 +304,13 @@ async def handle_receiver_location(request):
|
||||
"name": config["location"]["name"]
|
||||
})
|
||||
|
||||
async def handle_config(request):
|
||||
"""Return client-relevant configuration"""
|
||||
return web.json_response({
|
||||
"theme": config.get("theme", "desert"),
|
||||
"location": config["location"]
|
||||
})
|
||||
|
||||
async def handle_http(request):
|
||||
"""Serve static files"""
|
||||
path = request.path
|
||||
@@ -319,6 +328,7 @@ async def start_http_server():
|
||||
app = web.Application()
|
||||
app.router.add_get('/ws', websocket_handler)
|
||||
app.router.add_get('/api/receiver-location', handle_receiver_location)
|
||||
app.router.add_get('/api/config', handle_config)
|
||||
app.router.add_get('/{tail:.*}', handle_http)
|
||||
|
||||
runner = web.AppRunner(app)
|
||||
|
||||
Reference in New Issue
Block a user