mirror of
https://github.com/CopterExpress/clever-show.git
synced 2026-06-02 18:19:33 +00:00
Added file transfer from web to flask server
This commit is contained in:
@@ -7,16 +7,11 @@ app = Flask(__name__, static_url_path='/static')
|
||||
copters = []
|
||||
|
||||
|
||||
def response_handler(res, name, ip):
|
||||
print('\n\n\n', res, '\n\n\n', name, '\n\n\n', ip, '\n\n\n')
|
||||
return 1
|
||||
|
||||
|
||||
@app.route('/')
|
||||
def home():
|
||||
data = dict()
|
||||
data['clients'] = []
|
||||
# refresh_copters_list()
|
||||
refresh_copters()
|
||||
for client in Client.clients.keys():
|
||||
data['clients'].append([client, Client.clients[client].copter_id])
|
||||
return render_template('main.html', data=data)
|
||||
@@ -37,7 +32,7 @@ def refresh_copters():
|
||||
return jsonify({'m': 'Error'})
|
||||
|
||||
|
||||
@app.route('/selfcheck/selected')
|
||||
@app.route('/selfcheck/selected', methods=["GET", "POST"])
|
||||
def selfcheck_selected():
|
||||
data = dict()
|
||||
ip = request.args.get("ip")
|
||||
@@ -52,6 +47,8 @@ def selfcheck_selected():
|
||||
'time': copter.time,
|
||||
'name': copter.name,
|
||||
}
|
||||
data = {"anim_id": "No animation", "batt_voltage": 3.259999990463257, "cell_voltage": 1.0850000381469727,
|
||||
"ip": "192.168.43.31", "name": "CLever7", "selfcheck": "OK", "time": 1554723269.57106}
|
||||
return jsonify(data)
|
||||
|
||||
|
||||
@@ -69,9 +66,36 @@ def selfcheck_all():
|
||||
'time': copter.time,
|
||||
'name': copter.name,
|
||||
})
|
||||
data = [{"anim_id": "No animation", "batt_voltage": 4.259999990463257, "cell_voltage": 4.0850000381469727,
|
||||
"ip": "192.168.43.31", "name": "CLever7", "selfcheck": "OK", "time": 4554723269.57106}]
|
||||
data *= 12
|
||||
return jsonify(data)
|
||||
|
||||
|
||||
@app.route('/set/animation', methods=['GET', 'POST'])
|
||||
def set_animation():
|
||||
if request.method == 'POST':
|
||||
f = request.files['file']
|
||||
print(f, 'ip', request.args.get('ip'))
|
||||
return jsonify({'m': 'ok'})
|
||||
|
||||
|
||||
@app.route('/set/config', methods=['GET', 'POST'])
|
||||
def set_config():
|
||||
if request.method == 'POST':
|
||||
f = request.files['file']
|
||||
print(f, 'ip', request.args.get('ip'))
|
||||
return jsonify({'m': 'ok'})
|
||||
|
||||
|
||||
@app.route('/set/aruco', methods=['GET', 'POST'])
|
||||
def set_aruco():
|
||||
if request.method == 'POST':
|
||||
f = request.files['file']
|
||||
print(f, 'ip', request.args.get('ip'))
|
||||
return jsonify({'m': 'ok'})
|
||||
|
||||
|
||||
class ServerThread(threading.Thread):
|
||||
def run(self):
|
||||
server = Server()
|
||||
@@ -80,6 +104,6 @@ class ServerThread(threading.Thread):
|
||||
pass
|
||||
|
||||
|
||||
# server_thread = ServerThread()
|
||||
# server_thread.start()
|
||||
server_thread = ServerThread()
|
||||
server_thread.start()
|
||||
app.run(host='0.0.0.0', debug=False)
|
||||
|
||||
Reference in New Issue
Block a user