File size: 1,013 Bytes
b5b6910
941e798
 
095db3f
 
3940b7c
 
 
 
 
 
 
095db3f
b5b6910
c7bf148
 
b5b6910
 
c7bf148
 
4f26df3
c7bf148
 
 
3940b7c
4f26df3
3940b7c
 
 
 
 
941e798
326c62d
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
from flask import Flask, request
import requests
import time

app = Flask(__name__)
#get servo list from id
def get_servo_list(fileid):
    with open('database.txt', 'r') as file:
        for current_line, line_content in enumerate(file, 1):
            if current_line == fileid:
                return line_content.strip()
    return None

@app.route('/')
def main():
    return 'a very nice page, you must admit'

@app.route('/input')
def apirequests():
    # =?id,servo
    # this code filters the id out V
    full_query = request.query_string.decode('utf-8')
    if full_query.startswith('='):
        data = full_query[1:]
    #ends here ^ and saves in data
    id, servo = data.split(',')
    #splitting them into id and servo
    #then we can get the id from the database
    servolist = get_servo_list(id)
    one, two, three = servolist.split(',')
    return "servo 1: " + one + "servo two: " + two + "servo three:" + three
if __name__ == '__main__':
    app.run(host='0.0.0.0', port=5000, debug=False)