Python Flask Documentation

Elliott Barcoe-Walsh edited this page Feb 28, 2017 · 29 revisions

Here you will find the list of flask end points that are used in Visual Analytics. These end points are used to allow the front end ajax calls to communicate with our MySQL database. For more information on Flask, please read the documentation.

Flask End Points

@mod_auth.route('/home')
def index():

  • The / home route is our home page. Here we render the index.html file

@mod_auth.route('/get_test_set_statuses', methods=['GET', 'POST']) def get_test_set_statuses():

  • Receives a login token and a filter(0,1,2,3)
  • If filter = 0 we return all test_set_id's and their status back to the front end
  • Any other filter will return the test_set_id and status back to front end for appropriate filter
  • 0 = All test sets 1 = Running 3 = Complete 4 = Parked

@mod_auth.route('/get_test_set_details', methods=['GET', 'POST'])
def get_test_set_details():

  • Receives a login token and a test_set_id
  • For a given test_set_id:
    • Returns all test set details
    • Returns the login_uuids (Test takers unique token)
    • Returns the template ids

@mod_auth.route('/get_template_ids', methods=['GET', 'POST'])
def get_template_ids():

  • Receives a login token and a filter(0,1,2,3)
  • If filter = 0 we return all graph_types and template_id back to the front end
  • Any other filter will return the graph_type and template_id back to front end for appropriate filter

@mod_auth.route('/delete_test_set', methods=['GET', 'POST'])
def delete_test_set():

  • Receives a login token and a test_set_id
  • Deletes everything with the test_set_id from test_set_result, test_set_details, and test_set_template_list

@mod_auth.route('/delete_template', methods=['GET', 'POST'])
def delete_template():

  • Receives a login token and a template_id
  • Checks test_set_template_list to see if template is being used with a test
  • Deletes everything from test_set_result and templates

@mod_auth.route('/open_test', methods=['GET', 'POST'])
def open_test():

  • Receives a login_token and a test_set_id
  • Changes the status of the test to open in DB
  • Sends back a success or failed status to frontend

@mod_auth.route('/close_test', methods=['GET', 'POST'])
def close_test():

  • Receives a login_token and a test_set_id
  • Changes the status of the test to closed in the in DB
  • Sends back a success or failed status to frontend

@mod_auth.route('/trial_login', methods=['GET', 'POST'])
def trial_login():

  • Receives a login_uuid
  • Returns a JSON object with "Success" if login_uuid is found

def check_token(token):

  • Takes an admin token and checks it against the admin table and returns True or False

@mod_auth.route('/admin_login', methods=['GET','POST'])
def admin_login():

  • Takes and email and password and checks it against admin table
  • If email and password are correct, we check against the admin table if login_uuid is found
  • If not found a login_uuid is created for admin and persisted
  • The admin login_uuid are then returned to the front end

@mod_auth.route('/submit_user_trial_results', methods=['GET', 'POST'])
def submit_user_trial_results():

  • Receives a template_id, login_uuid, score, time, selected_point, and selected_class
  • Persists these into the DB in the test_set_user_results table
  • Returns a status of either success or fail

@mod_auth.route('/export_csv', methods=['GET', 'POST'])
def export_csv():

  • Receives an admin login and test_set_id
  • Selects all of the results from test_set_result for the given test set and formats it as a CSV and sends it back to front end

@mod_auth.route('/new_test_set', methods=['GET', 'POST'])
def new_test_set():

  • Receives a login token, test_set_id, template_id, wait_time, close_time, and uuid_count
  • Checks if test_set already exists
  • If not we Insert into test_set_details the test_set_id, wait_time, and close_time
  • Next for each template_id we insert into test_set_template_list the test_set_id, template_id, data_point_dict['class1_parent'],data_point_dict['class2_parent'],data_point_dict['class2_children'],data_point_dict['class1_children']
  • Next we need to create the UUID's so based on the uuid_count we create and persist the new UUID's into the db
  • Finally, we return a success or fail status to the front end.

@mod_auth.route('/get_next_test', methods=['GET', 'POST'])
def get_next_test():

  • Receives a login_uuid from the front end
  • Checks on a join of test_set_template_list and template_set_result to see if the template from test_set_template_list has been persisted into the test_set_template_list. If it is there, then there are no more remaining tests and the user is done. * If not we are going to persist that template into the test_set_results table and the user is ready for the next test.
  • Returns a status of success or fail to front end and a message saying that the template has been added or all templates are complete.

@mod_auth.route('/new_template', methods=['GET','POST'])
def new_template():

  • Receives a login_token, graph_type, total_data_points, and a template_id
  • Checks the templates table to see if the template already exists
  • If not it adds the template to the table
  • Returns a status of success or fail to the front end with a message saying the template has been added or the template already exists
You can’t perform that action at this time.
You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session.
Press h to open a hovercard with more details.