def browse(): """Show all recipes""" type_rows = db.execute("SELECT * FROM types") types = get_dict("type_id", type_rows) cuisine_rows = db.execute("SELECT * FROM cuisines") cuisines = get_dict("cuisine_id", cuisine_rows) appliance_rows = db.execute("SELECT * FROM appliances") appliances = get_dict("appliance_id", appliance_rows) # Query database for all recipes recipes = db.execute( "SELECT recipe_id, title, veggie, vegan, gluten, type_id, cuisine_id, prep_time, cook_time, appliance_id, servings FROM recipes" ) for recipe in recipes: recipe['type_id'] = types[recipe['type_id']]['type_name'] recipe['subtype'] = types[recipe['type_id']]['subtype'] recipe['cuisine_id'] = cuisines[recipe['cuisine_id']]['cuisine_name'] recipe['appliance_id'] = appliances[ recipe['appliance_id']]['appliance_name'] return render_template("table.html", browse=True, recipes=recipes)
def your_recipes(): """Show user's submitted recipes""" type_rows = db.execute("SELECT * FROM types") types = get_dict("type_id", type_rows) cuisine_rows = db.execute("SELECT * FROM cuisines") cuisines = get_dict("cuisine_id", cuisine_rows) appliance_rows = db.execute("SELECT * FROM appliances") appliances = get_dict("appliance_id", appliance_rows) # Query database for all the recipes the user has submitted recipes = db.execute( "SELECT recipe_id, title, veggie, vegan, gluten, type_id, cuisine_id, prep_time, cook_time, appliance_id, servings FROM recipes WHERE user_id = :user_id", user_id=session["user_id"]) for recipe in recipes: recipe['type_id'] = types[recipe['type_id']]['type_name'] recipe['subtype'] = types[recipe['type_id']]['subtype'] recipe['cuisine_id'] = cuisines[recipe['cuisine_id']]['cuisine_name'] recipe['appliance_id'] = appliances[ recipe['appliance_id']]['appliance_name'] return render_template("table.html", your_rep=True, recipes=recipes)
def index(): """Show user's favorites""" # Query database and convert lists to dicts type_rows = db.execute("SELECT * FROM types") types = get_dict("type_id", type_rows) cuisine_rows = db.execute("SELECT * FROM cuisines") cuisines = get_dict("cuisine_id", cuisine_rows) appliance_rows = db.execute("SELECT * FROM appliances") appliances = get_dict("appliance_id", appliance_rows) # https://stackoverflow.com/questions/10562915/selecting-rows-with-id-from-another-table # Query database for all the recipes the user has favorited recipes = db.execute( "SELECT recipe_id, title, veggie, vegan, gluten, type_id, cuisine_id, prep_time, cook_time, appliance_id, servings FROM recipes WHERE recipe_id IN (SELECT recipe_id FROM favorites WHERE user_id = :user_id)", user_id=session["user_id"]) # Maps ids to names without need for complicated INNER JOIN for recipe in recipes: recipe['type_id'] = types[recipe['type_id']]['type_name'] recipe['subtype'] = types[recipe['type_id']]['subtype'] recipe['cuisine_id'] = cuisines[recipe['cuisine_id']]['cuisine_name'] recipe['appliance_id'] = appliances[ recipe['appliance_id']]['appliance_name'] return render_template("table.html", favorites=True, recipes=recipes)
def create_charge(): """Returns POST Data.""" extracted = h.get_dict('url', 'args', 'form', 'data', 'origin', 'headers', 'files', 'json') charge_entry = Charge.from_dict(extracted['json']) db.session.add(charge_entry) db.session.commit() return h.jsonify(extracted)
def create_charge(): """Returns POST Data.""" extracted = h.get_dict( 'url', 'args', 'form', 'data', 'origin', 'headers', 'files', 'json') charge_entry = Charge.from_dict(extracted['json']) db.session.add(charge_entry) db.session.commit() return h.jsonify(extracted)
def delay_response(delay): """Returns a delayed response""" delay = min(float(delay), 10) time.sleep(delay) return jsonify( get_dict('url', 'args', 'form', 'data', 'origin', 'headers', 'files'))
def stream_n_messages(n): """Stream n JSON messages""" response = get_dict('url', 'args', 'headers', 'origin') n = min(n, 100) def generate_stream(): for i in range(n): response['id'] = i yield json.dumps(response) + '\n' return Response(generate_stream(), headers={ "Content-Type": "application/json", })
def certification_root(): if request.method == "POST": # expected data [equipment_type_id, worker_id] data = request.get_json() # sanitization if not data: return jsonify({"success": False, "message": "Missing body."}), 400 if not 'equipment_type_id' in data or not 'worker_id' in data: return jsonify({ "success": False, "message": "Missing body fields." }), 400 if not isinstance(data['equipment_type_id'], int) or not isinstance( data['worker_id'], int): return jsonify({ "success": False, "message": "Invalid body fields." }), 400 if not EquipmentType.query.get(data['equipment_type_id']): return jsonify({ "success": False, "message": "Equipment Type key not found." }), 404 if not Worker.query.get(data['worker_id']): return jsonify({ "success": False, "message": "Worker key not found." }), 404 # add to db certification = Certification(data['equipment_type_id'], data['worker_id']) db.session.add(certification) db.session.commit() return jsonify(get_dict(certification)) else: # get facilities certifications = Certification.query.all() return jsonify(get_dict_array(certifications))
def facility_root(): if request.method == "POST": # expected data [lat, lon] data = request.get_json() # sanitization if not data: return jsonify({"success": False, "message": "Missing body."}), 400 if not 'lat' in data or not 'lon' in data: return jsonify({ "success": False, "message": "Missing body fields." }), 400 if not isinstance(data['lat'], (int, float)) or not isinstance( data['lon'], (int, float)): return jsonify({ "success": False, "message": "Invalid body fields." }), 400 if data['lat'] < -90.0 or data['lat'] > 90.0: return jsonify({ "success": False, "message": "Latitude out of range." }), 400 if data['lon'] < -180.0 or data['lon'] > 180.0: return jsonify({ "success": False, "message": "Longitude out of range." }), 400 # add to db facility = Facility(data['lat'], data['lon']) db.session.add(facility) db.session.commit() return jsonify(get_dict(facility)) else: # get facilities facilities = Facility.query.all() return jsonify(get_dict_array(facilities))
def equipment_root(): if request.method == "POST": # expected data [equipment_type_id, facility_id] data = request.get_json() # sanitization if not data: return jsonify({"success": False, "message": "Missing body."}), 400 if not 'equipment_type_id' in data or not 'facility_id' in data: return jsonify({ "success": False, "message": "Missing body fields." }), 400 if not isinstance(data['equipment_type_id'], int) or not isinstance( data['facility_id'], int): return jsonify({ "success": False, "message": "Invalid body fields." }), 400 if not EquipmentType.query.get(data['equipment_type_id']): return jsonify({ "success": False, "message": "Equipment Type key not found." }), 404 if not Facility.query.get(data['facility_id']): return jsonify({ "success": False, "message": "Facility key not found." }), 404 # add to db equipment = Equipment(data['equipment_type_id'], data['facility_id']) db.session.add(equipment) db.session.commit() return jsonify(get_dict(equipment)) else: # get equipments equipments = Equipment.query.all() return jsonify(get_dict_array(equipments))
def worker_root(): if request.method == "POST": # expected data [name, shift] data = request.get_json() # sanitization if not data: return jsonify({"success": False, "message": "Missing body."}), 400 if not 'name' in data or not 'shift' in data: return jsonify({ "success": False, "message": "Missing body fields." }), 400 if not isinstance(data['name'], str) or not isinstance( data['shift'], str): return jsonify({ "success": False, "message": "Invalid body fields." }), 400 if len(data['name'].strip()) < 1 or len(data['name']) > 100: return jsonify({ "success": False, "message": "Name length out of range." }), 400 if len(data['shift'].strip()) < 1 or len(data['shift']) > 15: return jsonify({ "success": False, "message": "Shift length out of range." }), 400 # add to db worker = Worker(data['name'], data['shift']) db.session.add(worker) db.session.commit() return jsonify(get_dict(worker)) else: # get request workers = Worker.query.all() return jsonify(get_dict_array(workers))
def send_message(sid, scope, address, message): user_session = get_session(scope, address) if user_session.sid == sid: # trace_debug("Name={}. Message={}".format(address, message)) msg = get_dict(message) receiver = get_session(scope, msg['receiver'], False) if not receiver: reason = "User you tried is not registered! ({}, {})".format( scope, address) failed_response(sio, reason, address, sid) else: raw_send_read_msg = { "txn": msg["txn"], "text": msg['text'], "sender": address, "to": receiver.address } save_message = save_send_message(receiver, msg['txn'], set_json(raw_send_read_msg)) if save_message: if receiver and get_server_socket(sio, receiver.sid): new_message_response(sio, scope, msg['txn'], msg['text'], address, receiver.address, receiver.sid) receive_ack_response(sio, msg['txn'], scope, user_session.address, sid) trace_debug( "Message received by -->{}, SID: {}, TXN: {}, MSG: {}". format(receiver.address, receiver.sid, msg['txn'], msg['text'])) else: sent_ack_response(sio, msg['txn'], scope, user_session.address, sid) trace_debug( "Message sent to -->{}, SID: {}, TXN: {}, MSG: {}". format(receiver.address, receiver.sid, msg['txn'], msg['text'])) else: failed_response( sio, "DB STORE FAILED. MSG: {}, RAW MSG: {}".format( msg, raw_send_read_msg), address, sid) else: trace_info(">>>INVALID SESSION FOR {}".format(address)) sio.disconnect(sid)
def order(order_id): # get response order = Order.query.get(order_id) if order is None: return jsonify({ "success": False, "message": "Order with key not found!" }), 404 # build response res = get_dict(order) # add relations res['worker_name'] = order.worker.name if order.worker else None return jsonify(res)
def facility(fid): # get response facility = Facility.query.get(fid) if facility is None: return jsonify({ "success": False, "message": "Facility with key not found!" }), 404 res = get_dict(facility) # add relations res['equipments'] = [] for e in facility.equipments: res['equipments'].append({ "id": e.id, "name": e.equipment_type.name, "equipment_type_id": e.equipment_type_id }) res['orders'] = get_dict_array(facility.orders) return jsonify(res)
def worker(worker_id): # get response worker = Worker.query.get(worker_id) if worker is None: return jsonify({ "success": False, "message": "Worker with key not found!" }), 404 # build response res = get_dict(worker) # add relations res['certifications'] = [] for cert in worker.certifications: res['certifications'].append({ "name": cert.equipment_type.name, "id": cert.id }) res['orders'] = get_dict_array(worker.orders) return jsonify(res)
def tag_api(): # check for signin if session.get('user_id') is None: return jsonify({"success": False, "message": "Not logged in!"}) # process request if request.method == "POST": # add tag to db data = request.get_json() tag = Tag(data['name']) db.session.add(tag) db.session.commit() return jsonify({"success": True, "tag": get_dict(tag)}) else: # get tags tags = Tag.query.all() return jsonify({"success": True, "tags": get_dict_array(tags)})
def view_get(): """Returns GET Data.""" return jsonify(get_dict('url', 'args', 'headers', 'origin'))
def view_headers(): """Returns HTTP HEADERS.""" return jsonify(get_dict('headers'))
def entry_api(): # check for signin if session.get('user_id') is None: return jsonify({"success": False, "message": "Not logged in!"}) if request.method == "POST": # add entry to db data = request.get_json() # check required params if not data: return jsonify({"success": False, "message": "No body!"}) if 'text' not in data: return jsonify({"success": False, "message": "No text!"}) if 'tag_id' not in data: return jsonify({"success": False, "message": "No tag id!"}) if 'p_level' not in data: return jsonify({"success": False, "message": "No productivity level!"}) # default timeframe t_from = datetime.utcnow().timestamp() t_to = datetime.utcnow().timestamp() # edit for last hour t_from = t_from - 3600 # edit if params given if data and 'from' in data: t_from = data['from'] if data and 'to' in data: t_to = data['to'] # convert params to datetime try: t_from = datetime.fromtimestamp(int(t_from)) t_to = datetime.fromtimestamp(int(t_to)) except: print("error on time conversion or out of bound") return jsonify({"success": False, "message": "Intervals invalid!"}) # round to nearest hour t_from.replace(microsecond=0, second=0, minute=0) t_to.replace(microsecond=0, second=0, minute=0) # add the entries while t_from < t_to: # add to db entry = Entry(data['text'], t_from, session.get('user_id'), data['tag_id'], data['p_level']) db.session.add(entry) db.session.commit() # increase time t_from = t_from + timedelta(seconds=3600) return jsonify({"success": True}) else: # default timeframe t_from = datetime(1970,1,2).timestamp() t_to = datetime.utcnow().timestamp() # save params if given if request.args.get('from'): t_from = request.args.get('from') if request.args.get('to'): t_to = request.args.get('to') # convert interval to datetime try: t_from = datetime.fromtimestamp(int(t_from)) t_to = datetime.fromtimestamp(int(t_to)) except: print("error on time conversion or out of bound") return jsonify({"success": False, "message": "Intervals invalid!"}) # get current user user = User.query.get(session['user_id']) # filter with time entries = user.entries.filter(Entry.time >= t_from, Entry.time <= t_to).order_by(Entry.time).all() # result builder result = [] for e in entries: ent = get_dict(e) ent['tag_name'] = e.tag.name ent['hour'] = e.time.hour result.append(ent) return jsonify({"success": True, "entries": result})
def view_post(): '''Return POST Data''' return jsonify( get_dict('url', 'args', 'form', 'data', 'origin', 'headers', 'files', 'json'))
def view_get(): '''Return GET Data.''' return jsonify(get_dict('url', 'args', 'headers', 'origin'))
def view_headers(): '''Return HTTP HEADERS''' return jsonify(get_dict('headers'))
def view_deflate_encoded_content(): """Returns Deflate-Encoded Data.""" return jsonify( get_dict('origin', 'headers', method=request.method, deflated=True))
def view_gzip_encoded_content(): '''Return gzip-encoded Data''' return jsonify( get_dict('origin', 'headers', method=request.method, gzipped=True))
def solve_wbm(from_nodes, to_nodes, wt, df, slotdict, min_exp, min_skill, stress_slots, target_delta, flex_shifts, slot_duration): ''' A wrapper function that uses pulp to formulate and solve a WBM''' exp_dict = helpers.get_dict(df, 'experience') skill_dict = helpers.get_dict(df, 'skill') gap_dict = helpers.get_dict(df, 'gap') prev_slot = input_creator.get_prev_slots(df, slot_duration) prob = LpProblem("WBM Problem", LpMaximize) # Create The Decision variables choices = LpVariable.dicts("e", (from_nodes, to_nodes), 0, 1, LpInteger) # Add the objective function prob += lpSum([ wt[u][v] * choices[u][v] for u in from_nodes for v in to_nodes ]), "Total weights of selected edges" # For all s, j, \sum_k x(s,k,j,1) + x(s,k,j,0) \leq 1. Guarantees that each slot is used at most once. for u in from_nodes: for v in helpers.get_slots_of_type(to_nodes, 0): x = helpers.get_alt_slot( v, prev_slot) #sees if slot is potential 4hr (has alternate node) if x != None: prob += lpSum([choices[u][v] + choices[u][x]]) <= 1, "" else: prob += lpSum([choices[u][v]]) <= 1, "" # For all s,k, \sum_j x(s,k,j,1) + x(s,k,j,0)+ x(s,k-1,j,1) + x(s,k-1,j,0) \leq 1. Guarantees that each slot is used at most once, and also no overlapping slots. for u in from_nodes: name = u.split('_')[:1][0] j_nodes = helpers.get_student_nodes(name, from_nodes) #get student's overlap dict min_gap = gap_dict[name] slots = slotdict.keys() overlaps = input_creator.get_overlaps(slots, min_gap, slot_duration) for v in helpers.get_slots_of_type(to_nodes, 0): x = helpers.get_alt_slot( v, prev_slot) #sees if slot is potential 4hr (has alternate node) k = helpers.get_slot(v) if x != None and k in overlaps.keys(): overlap_slots = overlaps[k] #get overlap nodes as list overlap_nodes = [] for slot in overlap_slots: node_0 = str(slot) + constants.SINGLE_SLOT_SUFFIX overlap_nodes.append(node_0) if helpers.is_double(slot, prev_slot): node_1 = str(slot) + constants.DOUBLE_SLOT_SUFFIX overlap_nodes.append(node_1) for k in overlap_nodes: k_x = helpers.get_alt_slot(k, prev_slot) if k_x != None: prob += lpSum([ choices[u][v] + choices[u][x] + choices[u][k] + choices[u][k_x] for u in j_nodes ]) <= 1, "" else: prob += lpSum([ choices[u][v] + choices[u][x] + choices[u][k] for u in j_nodes ]) <= 1, "" if x != None: prob += lpSum([choices[u][v] + choices[u][x] for u in j_nodes]) <= 1, "" if k in overlaps.keys(): overlap_slots = overlaps[k] #get overlap nodes as list overlap_nodes = [] for slot in overlap_slots: node_0 = str(slot) + constants.SINGLE_SLOT_SUFFIX overlap_nodes.append(node_0) if helpers.is_double(slot, prev_slot): node_1 = str(slot) + constants.DOUBLE_SLOT_SUFFIX overlap_nodes.append(node_1) for l in overlap_nodes: prob += lpSum( [choices[u][v] + choices[u][l] for u in j_nodes]) <= 1, "" # Guarantees that total sum of shifts is slotdict sum + flex_shifts total_shifts = 0 for slot in slotdict: total_shifts += slotdict[slot] total_shifts += flex_shifts all_single_shifts = helpers.get_slots_of_type(to_nodes, 0) all_double_shifts = helpers.get_slots_of_type(to_nodes, 1) all_shifts = all_single_shifts + all_double_shifts prob += lpSum([choices[u][v] for u in from_nodes for v in all_shifts]) <= total_shifts, "" # For all k, \sum_{s,j} x(s,k,j,1) + x(s,k,j,0) \leq c_k. Guarantees that each slot is within +target_delta ta of slotdict amount for v in helpers.get_slots_of_type(to_nodes, 0): slot = helpers.get_slot(v) x = helpers.get_alt_slot( v, prev_slot ) #sees if slot is potential 4hr (has alternate node) and returns node if yes if x != None: prob += lpSum([choices[u][v] + choices[u][x] for u in from_nodes ]) <= (slotdict[slot] + target_delta), "" else: prob += lpSum([choices[u][v] for u in from_nodes ]) <= (slotdict[slot] + target_delta), "" for v in helpers.get_slots_of_type(to_nodes, 0): slot = helpers.get_slot(v) x = helpers.get_alt_slot( v, prev_slot ) #sees if slot is potential 4hr (has alternate node) and returns node if yes if x != None: prob += lpSum([choices[u][v] + choices[u][x] for u in from_nodes]) >= slotdict[slot], "" else: prob += lpSum([choices[u][v] for u in from_nodes]) >= slotdict[slot], "" # For all s,k,j x(s,k,j,1) \leq \sum_\ell x(s,k-2,\ell,0)+x(s,k-2,\ell,1). Guarantees that you get to be the end of a 4-hour slot only if you're actually part of the slot before it. for u in from_nodes: #make list of student nodes name = u.split('_')[:1][0] j_nodes = helpers.get_student_nodes(name, from_nodes) for x in helpers.get_slots_of_type(to_nodes, 1): prev = helpers.get_prev_slot(x, prev_slot) prev_x = helpers.get_alt_slot(prev, prev_slot) if prev_x != None: prob += lpSum([ choices[j][x] - choices[j][prev] - choices[j][prev_x] for j in j_nodes ]) <= 0, "" else: prob += lpSum( [choices[j][x] - choices[j][prev] for j in j_nodes]) <= 0, "" # For all s,k, j x(s,k,j,0) \leq 1-\sum_\ell x(s,k-2,\ell,0)+x(s,k-2,\ell,1). Guarantees that you only get an isolated 2-hour slot if you're not part of the slot before it. for u in from_nodes: #make list of student nodes name = u.split('_')[:1][0] j_nodes = helpers.get_student_nodes(name, from_nodes) for v in helpers.get_slots_of_type(to_nodes, 0): prev = helpers.get_prev_slot(v, prev_slot) if prev != None: prev_x = helpers.get_alt_slot(prev, prev_slot) if prev_x != None: prob += lpSum([ choices[j][v] + choices[j][prev] + choices[j][prev_x] for j in j_nodes ]) <= 1, "" else: prob += lpSum( [choices[j][v] + choices[j][prev] for j in j_nodes]) <= 1, "" # make sure each student's shift is used once for u in from_nodes: prob += lpSum([choices[u][v] for v in to_nodes]) <= 1, "" # make sure each slot has >=2 experienced TA's for v in helpers.get_slots_of_type(to_nodes, 0): slot = helpers.get_slot(v) x = helpers.get_alt_slot( v, prev_slot ) #sees if slot is potential 4hr (has alternate node) and returns node if yes exp_studs_nodes = [] for student in exp_dict: if exp_dict[student] > 0: # if experienced, add their nodes to list j_nodes = helpers.get_student_nodes(student, from_nodes) exp_studs_nodes.extend(j_nodes) if x != None: prob += lpSum( [choices[u][v] + choices[u][x] for u in exp_studs_nodes]) >= min_exp, "" else: prob += lpSum([choices[u][v] for u in exp_studs_nodes]) >= min_exp, "" #make sure each stress slot has min_skill skilled ta's stress_nodes = [] for slot in stress_slots: stress_nodes.append(slot + constants.SINGLE_SLOT_SUFFIX) for v in helpers.get_slots_of_type(stress_nodes, 0): slot = helpers.get_slot(v) x = helpers.get_alt_slot(v, prev_slot) skill_studs_nodes = [] for student in skill_dict: if skill_dict[ student] > 2: # if highly skilled student, add their nodes to list j_nodes = helpers.get_student_nodes(student, from_nodes) skill_studs_nodes.extend(j_nodes) if x != None: prob += lpSum( [choices[u][v] + choices[u][x] for u in skill_studs_nodes]) >= min_skill, "" else: prob += lpSum([choices[u][v] for u in skill_studs_nodes]) >= min_skill, "" # The problem data is written to an .lp file # prob.writeLP("WBM.lp") # The problem is solved using PuLP's choice of Solver prob.solve() # The status of the solution is printed to the screen print("Status:", LpStatus[prob.status]) return (prob)
def view_patch(): """Return PATCH Data.""" return jsonify( get_dict('url', 'args', 'form', 'data', 'origin', 'headers', 'files', 'json'))
def register(sid: str, scope: str, address: str): if (no_session(sid=sid) or no_session( scope=scope, address=address)) and sid and scope and address: sid = sid.strip() scope = scope.strip() address = address.strip() if scope not in SCOPE_WHITE_LIST: failed_response(sio, "Wrong APP/Scope", address, sid) else: user_session = get_session(scope, address) if user_session and user_session.is_online == 1: try: if get_server_socket(sio, user_session.sid): sio.disconnect(user_session.sid) except KeyError as e: trace_debug( str(e) + "-->No SID available on server as {}".format( user_session.sid)) remove_session(user_session.sid) user_session = set_session(sid, scope, address) if user_session: success_response( sio, "Session created for {}".format(user_session.address), user_session.address, sid) user_list_response(sio, scope) new_message = get_user_message(user_session) if new_message: for msg in new_message: msg_dict = get_dict(msg.message) if msg.status == MESSAGE_STATUS['buyer']: if update_message_ack(msg.key, user_session): trace_debug( "ACK Done and Removed for {}. ADDRESS: {}, SID:: {}. Key:: {}" .format(msg.message, user_session.address, sid, msg.key)) buyer_receive_ack_response( sio, scope, msg.key, user_session.address, sid) else: failed_response( sio, "DB ERROR FOR ACK {}. user {}. Message Key:: {}" .format(msg.message, user_session.address, msg.key), user_session.address, user_session.sid) else: new_message_response(sio, scope, msg.key, msg_dict.get('text', None), msg_dict.get('sender', None), user_session.address, sid) receiver = get_session(scope, msg_dict.get('sender', None)) # If Sender and receiver both are available if receiver and get_server_socket(sio, receiver.sid): # send receive ack for receive to receiver receive_ack_response(sio, msg_dict['txn'], scope, receiver.address, receiver.sid) if update_message_ack(msg_dict["txn"], receiver): # send receive ack for buyer/targeted user buyer_receive_ack_response( sio, scope, msg_dict['txn'], receiver.address, receiver.sid) trace_debug( "ACK DONE and removed {} with SID:: {}, TXN:: {}" .format(receiver.address, receiver.sid, msg_dict['txn'])) else: trace_info( "---------Receiver missing check sockets-------" ) trace_info(receiver) trace_debug( "Receiver {} not found. TXN:: {}".format( msg_dict['sender'], msg_dict['txn'])) trace_debug("SESSION: {}, SID: {}".format( USER_SESSION, SESSION_SID)) else: trace_debug("No message found for {}, SID:: {}".format( address, sid)) else: failed_response( sio, "User session establishment failed for {}. Try again.". format(address), address, sid) sio.disconnect(sid) else: trace_info("USER SESSION:: {}".format(USER_SESSION)) trace_info("USER SID:: {}".format(SESSION_SID)) reason = "Invalid Request. Address: {}, Session: {}, App:: {}".format( address, sid, scope) failed_response(sio, reason, address, sid) sio.disconnect(sid)
def view_post(): """Returns POST Data.""" return jsonify( get_dict('url', 'args', 'form', 'data', 'origin', 'headers', 'files', 'json'))
def view_delete(): """Returns DELETE Data.""" return jsonify( get_dict('url', 'args', 'form', 'data', 'origin', 'headers', 'files', 'json'))
def view_gzip_encoded_content(): """Returns Gzip-Encoded Data.""" return jsonify( get_dict('origin', 'headers', method=request.method, gzipped=True))
def view_brotli_encode_content(): """Returns Brotli-Encoded Data.""" return jsonify( get_dict('origin', 'headers', method=request.method, brotli=True))