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)