diff --git a/python/api.py b/python/api.py index c957cd4..d20972d 100644 --- a/python/api.py +++ b/python/api.py @@ -2,6 +2,8 @@ from flask import Flask, json, request import os app = Flask(__name__) +name = "Aviation Assistant" +version = "v.2.7.2-aaf68f9bf2b51806300f7830f67f5254f04a90a2" @app.route('/brightness',methods = ['POST']) def brightness(): @@ -13,11 +15,29 @@ def brightness(): status = os.popen('sudo cat /sys/class/backlight/rpi_backlight/brightness').read() return status +@app.route('/information',methods = ['GET']) +def information(): + ip = os.popen("ip -4 addr show wlan0 | grep -oP '(?<=inet\s)\d+(\.\d+){3}'").read() + json = { + "name": name, + "version": version, + "ip": ip + } + return json + @app.route('/connection',methods = ['GET']) def connection(): if request.method == 'GET': return "OK" +@app.route('/authentication',methods = ['POST']) +def authentication(): + json = request.get_json() + if json['username'] == "npease" and json['password'] == "1118": + return "OK" + else: + return "NO" + @app.route('/audio',methods = ['POST']) def volume(): if request.method == 'POST': diff --git a/python/api_pc.py b/python/api_pc.py index 73f926e..ad5ee56 100644 --- a/python/api_pc.py +++ b/python/api_pc.py @@ -13,6 +13,28 @@ def brightness(): status = os.popen('sudo cat /sys/class/backlight/rpi_backlight/brightness').read() return status +@app.route('/connection',methods = ['GET']) +def connection(): + if request.method == 'GET': + return "OK" + +@app.route('/authentication',methods = ['POST']) +def authentication(): + json = request.get_json() + if json['username'] == "npease" and json['password'] == "1118": + return "OK" + else: + return "NO" + +@app.route('/information',methods = ['GET']) +def information(): + ip = os.popen("ip -4 addr show wlan0 | grep -oP '(?<=inet\s)\d+(\.\d+){3}'").read() + json = { + "name": name, + "version": version, + "ip": ip + } + return json @app.route('/audio',methods = ['POST']) def volume():