<commit_before>from flask import Flask
from flask import jsonify
import json
import database


app = Flask(__name__)


@app.after_request
def after_request(response):
    response.headers.add('Access-Control-Allow-Origin', '*')
    response.headers.add('Access-Control-Allow-Headers', 'Content-Type,Authorization')
    response.headers.add('Access-Control-Allow-Methods', 'GET,PUT,POST,DELETE')
    return response


@app.route('/')
def indexPage():
    return 'Please use a path to access one of the provided methods.'


@app.route('/test')
def testPage():
    return render_template('testFiles/test.html')


@app.route('/test/validateLogin')
def testValidLogin():
    validityString = database.valLogin('user1', 'pass1')
    return jsonify(valid=validityString)


@app.route('/accounts/validateLogin', methods=['GET', 'PUT', 'OPTIONS'])
def validateLogin():
    validityString = 'false'
    # Input: json
    # username: string, password: string
    # set cookie: username, session hash

    inputJsonLib = request.view_args
    print inputJsonLib['username']
    
    validityString = database.valLogin(inputJsonLib['username'], inputJsonLib['password'])

    return jsonify(valid=validityString)


@app.route('/accounts/createAccount', methods=['PUT'])
def createAccount():
    # Outcomes: success, error_exists, error_invalid
    # firstName, surname, email, password, teamCaptain, accessibility
    outcome = 'success'
    
    inputJsonLib = request.view_args
    
    email = inputJsonLib['email']
    username = inputJsonLib['username']
    password = <PASSWORD>Lib['password']
    firstname = inputJsonLib['firstName']
    lastname = inputJsonLib['surname']
    teamcaptain = inputJsonLib['teamCaptain']
    accessibility = inputJsonLib['accessibility']
    
    outcome = database.createAccount(username, password, firstname, lastname, email, teamcaptain, accessibilityNeeds)
    
    return jsonify(status=outcome)


@app.route('/accounts/<username>/getDetails', methods=['GET'])
def getDetails(username):
    # firstName, surname, email, teamCaptain, accessibility
    outcome = 'success'
    
    return jsonify(status=outcome)


@app.route('/routes/addRoute', methods=['POST'])
def addRoute(routeName):
    # Outcomes: success, error_exists, error_invalid
    outcome = 'success'<commit_msg>Daniel getDetails<commit_after>from flask import Flask
from flask import jsonify
import json
import database


app = Flask(__name__)


@app.after_request
def after_request(response):
    response.headers.add('Access-Control-Allow-Origin', '*')
    response.headers.add('Access-Control-Allow-Headers', 'Content-Type,Authorization')
    response.headers.add('Access-Control-Allow-Methods', 'GET,PUT,POST,DELETE')
    return response


@app.route('/')
def indexPage():
    return 'Please use a path to access one of the provided methods.'


@app.route('/test')
def testPage():
    return render_template('testFiles/test.html')


@app.route('/test/validateLogin')
def testValidLogin():
    validityString = database.valLogin('user1', '<PASSWORD>')
    return jsonify(valid=validityString)


@app.route('/accounts/validateLogin', methods=['GET', 'PUT', 'OPTIONS'])
def validateLogin():
    validityString = 'false'
    # Input: json
    # username: string, password: string
    # set cookie: username, session hash

    inputJsonLib = request.view_args
    print inputJsonLib['username']
    
    validityString = database.valLogin(inputJsonLib['username'], inputJsonLib['password'])

    return jsonify(valid=validityString)


@app.route('/accounts/createAccount', methods=['PUT'])
def createAccount():
    # Outcomes: success, error_exists, error_invalid
    # firstName, surname, email, password, teamCaptain, accessibility
    outcome = 'success'
    
    inputJsonLib = request.view_args
    
    email = inputJsonLib['email']
    username = inputJsonLib['username']
    password = <PASSWORD>Lib['password']
    firstname = inputJsonLib['firstName']
    lastname = inputJsonLib['surname']
    teamcaptain = inputJsonLib['teamCaptain']
    accessibility = inputJsonLib['accessibility']
    
    outcome = database.createAccount(username, password, firstname, lastname, email, teamcaptain, accessibilityNeeds)
    
    return jsonify(status=outcome)


@app.route('/accounts/<username>/getDetails', methods=['GET'])
def getDetails(username):
    # firstName, surname, email, teamCaptain, accessibility
    outcome = 'success'
    inputJsonLib = request.view_args
    validityString = database.getDets(inputJsonLib['username'])
    return jsonify(status=outcome)


@app.route('/routes/addRoute', methods=['POST'])
def addRoute(routeName):
    # Outcomes: success, error_exists, error_invalid
    outcome = 'success'
{'fraction_non_alphanumeric': 0.1293194827220691, 'fraction_numerical': 0.0006359974560101759, 'mean_word_length': 4.80319803198032, 'pattern_counts': {'":': 0, '<': 8, '<?xml version=': 0, '>': 8, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1589251', 'n_tokens_mistral': 1396, 'n_tokens_neox': 1352, 'n_words': 294}