mirror of
https://github.com/DJ2LS/FreeDATA
synced 2024-05-14 08:04:33 +00:00
small adjustments to api validation, hopefully catching mygrid 4/6 error
This commit is contained in:
parent
419f7732df
commit
4a34386c26
|
@ -1,5 +1,16 @@
|
||||||
import re
|
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):
|
def validate_freedata_callsign(callsign):
|
||||||
#regexp = "^[a-zA-Z]+\d+\w+-\d{1,2}$"
|
#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
|
regexp = "^[A-Za-z0-9]{1,7}-[0-9]{1,3}$" # still broken - we need to allow all ssids form 0 - 255
|
||||||
|
|
|
@ -96,6 +96,9 @@ def index():
|
||||||
@app.route('/config', methods=['GET', 'POST'])
|
@app.route('/config', methods=['GET', 'POST'])
|
||||||
def config():
|
def config():
|
||||||
if request.method in ['POST']:
|
if request.method in ['POST']:
|
||||||
|
|
||||||
|
if not validations.validate_remote_config(request.json):
|
||||||
|
return api_abort("wrong config", 500)
|
||||||
# check if config already exists
|
# check if config already exists
|
||||||
if app.config_manager.read() == request.json:
|
if app.config_manager.read() == request.json:
|
||||||
return api_response(request.json)
|
return api_response(request.json)
|
||||||
|
|
Loading…
Reference in a new issue