Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -3,6 +3,13 @@ import requests
|
|
| 3 |
import time
|
| 4 |
|
| 5 |
app = Flask(__name__)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 6 |
|
| 7 |
@app.route('/')
|
| 8 |
def main():
|
|
@@ -15,8 +22,12 @@ def apirequests():
|
|
| 15 |
full_query = request.query_string.decode('utf-8')
|
| 16 |
if full_query.startswith('='):
|
| 17 |
data = full_query[1:]
|
| 18 |
-
#ends here and saves in data
|
| 19 |
id, servo = data.split(',')
|
| 20 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 21 |
if __name__ == '__main__':
|
| 22 |
app.run(host='0.0.0.0', port=5000, debug=False)
|
|
|
|
| 3 |
import time
|
| 4 |
|
| 5 |
app = Flask(__name__)
|
| 6 |
+
#get servo list from id
|
| 7 |
+
def get_servo_list(fileid):
|
| 8 |
+
with open('database.txt', 'r') as file:
|
| 9 |
+
for current_line, line_content in enumerate(file, 1):
|
| 10 |
+
if current_line == fileid:
|
| 11 |
+
return line_content.strip()
|
| 12 |
+
return None
|
| 13 |
|
| 14 |
@app.route('/')
|
| 15 |
def main():
|
|
|
|
| 22 |
full_query = request.query_string.decode('utf-8')
|
| 23 |
if full_query.startswith('='):
|
| 24 |
data = full_query[1:]
|
| 25 |
+
#ends here ^ and saves in data
|
| 26 |
id, servo = data.split(',')
|
| 27 |
+
#splitting them into id and servo
|
| 28 |
+
#then we can get the id from the database
|
| 29 |
+
servolist = get_servo_list(id)
|
| 30 |
+
one, two, three = servolist.split(',')
|
| 31 |
+
return "servo 1: " + one + "servo two: " + two + "servo three:" + three
|
| 32 |
if __name__ == '__main__':
|
| 33 |
app.run(host='0.0.0.0', port=5000, debug=False)
|