small adjustments to api validation, hopefully catching mygrid 4/6 error

This commit is contained in:
DJ2LS 2024-02-25 21:08:45 +01:00
parent 419f7732df
commit 4a34386c26
2 changed files with 14 additions and 0 deletions

View file

@ -1,5 +1,16 @@
import re
def validate_remote_config(config):
if not config:
return
mygrid = config["STATION"]["mygrid"]
if len(mygrid) != 6:
raise ValueError(f"Gridsquare must be 6 characters!")
return True
def validate_freedata_callsign(callsign):
#regexp = "^[a-zA-Z]+\d+\w+-\d{1,2}$"
regexp = "^[A-Za-z0-9]{1,7}-[0-9]{1,3}$" # still broken - we need to allow all ssids form 0 - 255

View file

@ -96,6 +96,9 @@ def index():
@app.route('/config', methods=['GET', 'POST'])
def config():
if request.method in ['POST']:
if not validations.validate_remote_config(request.json):
return api_abort("wrong config", 500)
# check if config already exists
if app.config_manager.read() == request.json:
return api_response(request.json)