<commit_before>import os
import jinja2
import re
import ldapquery
from phabquery import PhabricatorQuerier
import json
from collections import defaultdict
from flask import Flask, render_template, request, Response, session, redirect, flash, url_for

import logging
logging.basicConfig(level=logging.DEBUG)
logger = logging.getLogger('tools.contact')

app = Flask(__name__)
app.secret_key = <KEY>'
@app.route("/")
def index():
    return render_template('index.html')

@app.route("/<identifier>")
def query(identifier):
    return render_template('index.html', value=identifier)

@app.route("/", methods=['POST'])
def submit():
    identifier = request.form['identifier']
    logger.debug('Identifier is %r' % identifier)
    if not re.match(r"^[ a-zA-Z0-9\-\.]+$", identifier):
       return 'Identifier must be [a-zA-Z0-9]', 500 

    q = ldapquery.LDAPQuerier()
    pq = PhabricatorQuerier()

    wildcard = len(identifier) >= 3
    parts = []

    q.connect()
    user_data = q.user_search(identifier, wildcard)
    group_data = q.group_search(identifier, wildcard)
    q.disconnect()

    for info in user_data.values():
        info['type'] = 'ldap'
<commit_msg>move secrets to json file<commit_after>import os
import jinja2
import re
import ldapquery
from phabquery import PhabricatorQuerier
import json
from collections import defaultdict
from flask import Flask, render_template, request, Response, session, redirect, flash, url_for

import logging
logging.basicConfig(level=logging.DEBUG)
logger = logging.getLogger('tools.contact')

secrets = json.load(open('secrets.json'))

app = Flask(__name__)

app.secret_key = secrets['flask_app_key']

@app.route("/")
def index():
    return render_template('index.html')

@app.route("/<identifier>")
def query(identifier):
    return render_template('index.html', value=identifier)

@app.route("/", methods=['POST'])
def submit():
    identifier = request.form['identifier']
    logger.debug('Identifier is %r' % identifier)
    if not re.match(r"^[ a-zA-Z0-9\-\.]+$", identifier):
       return 'Identifier must be [a-zA-Z0-9]', 500 

    q = ldapquery.LDAPQuerier()
    pq = PhabricatorQuerier()

    wildcard = len(identifier) >= 3
    parts = []

    q.connect()
    user_data = q.user_search(identifier, wildcard)
    group_data = q.group_search(identifier, wildcard)
    q.disconnect()

    for info in user_data.values():
        info['type'] = 'ldap'

{'fraction_non_alphanumeric': 0.13853172957279136, 'fraction_numerical': 0.007465781833264205, 'mean_word_length': 4.371937639198218, 'pattern_counts': {'":': 0, '<': 6, '<?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': '1572808', 'n_tokens_mistral': 797, 'n_tokens_neox': 764, 'n_words': 190}