-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathserver.py
43 lines (32 loc) · 1019 Bytes
/
server.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
from flask import Flask, request, jsonify
from werkzeug.utils import secure_filename
import matlab.engine
import os
import time
app = Flask(__name__)
eng = matlab.engine.start_matlab()
@app.route("/", methods=["GET"])
def home():
return "CAU-IoT-Project-Design-2023"
@app.route("/is-connected", methods=["GET"])
def isConnected():
return "connected"
# 클라이언트로부터 센서 데이터 값 받기
@app.route("/save-sensor-data", methods=["POST"])
def saveSensorData():
if request.method == "POST":
file = request.files["file"]
filename = secure_filename(file.filename)
file.save("./" + filename)
return "OK"
# RSSI-based Localization
@app.route("/rssi-measure", methods = ["GET"])
def rssiMeasure():
if request.method == "GET":
eng.addpath(os.getcwd())
knnResult = eng.doKNNPrediction(10, 10, 10)
print(knnResult)
time.sleep(1.5)
return str(knnResult)
if __name__ == "__main__":
app.run("0.0.0.0", port=8080)