add SMS generation via user API
This commit is contained in:
parent
44122f677a
commit
b9c9cf8cc3
29
web/app.py
29
web/app.py
|
|
@ -7171,20 +7171,37 @@ Name: <strong>''' + p.name + '''</strong> - Port: <strong>''' + str(
|
||||||
|
|
||||||
return render_template('aprs_page.html', markup_content = Markup(content))
|
return render_template('aprs_page.html', markup_content = Markup(content))
|
||||||
|
|
||||||
@app.route('/api/<user>/<key>/<func>', methods=['POST', 'GET'])
|
# User API endpoint, for apps, etc.
|
||||||
def api_endpoint(user, key, func):
|
@app.route('/api/<user>/<key>', methods=['POST'])
|
||||||
|
def api_endpoint(user, key):
|
||||||
|
api_data = request.json
|
||||||
|
print(api_data)
|
||||||
try:
|
try:
|
||||||
u = User.query.filter(User.username == user).first()
|
u = User.query.filter(User.username == user).first()
|
||||||
if key in u.api_keys:
|
if key in u.api_keys:
|
||||||
if 'msg' in func:
|
if 'dmr_id' in api_data and 'sms' in api_data:
|
||||||
print('msg')
|
# def sms_que_add(_snd_call, _rcv_call, _snd_id, _rcv_id, _msg_type, _call_type, _server, _system_name, _msg):
|
||||||
return 'Your username is ' + u.username
|
sms_que_add(user, '', 0, api_data['dmr_id'], 'motorola', 'unit', api_data['gateway'], '', 'From: ' + user + '. ' + api_data['sms'])
|
||||||
|
msg = jsonify(status='Sucess',
|
||||||
|
reason='Added SMS to que')
|
||||||
|
response = make_response(msg, 200)
|
||||||
|
if 'dmr_id' in api_data and 'sms' in api_data and 'gateway' not in api_data:
|
||||||
|
msg = jsonify(status='Not added to que',
|
||||||
|
reason='Gateway not specified')
|
||||||
|
response = make_response(msg, 500)
|
||||||
|
|
||||||
|
|
||||||
|
return response
|
||||||
|
|
||||||
else:
|
else:
|
||||||
return 'Not Authenticated'
|
msg = jsonify(status='Access Denied',
|
||||||
|
reason='Not Authorized')
|
||||||
|
response = make_response(msg, 401)
|
||||||
|
return response
|
||||||
except:
|
except:
|
||||||
return 'Error'
|
return 'Error'
|
||||||
|
|
||||||
|
# Server endpoint
|
||||||
@app.route('/svr', methods=['POST'])
|
@app.route('/svr', methods=['POST'])
|
||||||
def svr_endpoint():
|
def svr_endpoint():
|
||||||
hblink_req = request.json
|
hblink_req = request.json
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1 @@
|
||||||
|
curl --header "Content-Type: application/json" --request POST --data '{"gateway": "Data", "dmr_id": 1234567, "sms": "this is a test"}' http://localhost:8080/api/<your_call>/<your_api_key>
|
||||||
Loading…
Reference in New Issue