<commit_before>import wsgi_server
import os
from werkzeug.wsgi import SharedDataMiddleware
import config
from cas import CASMiddleware
import logging
from werkzeug.contrib.sessions import FilesystemSessionStore
from werkzeug.wrappers import Response

#logging.basicConfig(level=logging.DEBUG)

#This function is called if:
# Not authenticated
# the ignore_redirect regex matches the (full) url pattern
def ignored_callback(environ, start_response):
    response = Response('{"Error":"NotAuthenticated"}')
#    response.status = '401 Unauthorized'
    response.status = '200 OK'
    response.headers['Content-Type'] = 'application/json'

    return response(environ, start_response)

application = wsgi_server.application

application = SharedDataMiddleware(application, {
    '/static': os.path.join(os.path.dirname(__file__), 'static')
})

if config.CAS_SERVICE != '':
  fs_session_store = FilesystemSessionStore()
  application = CASMiddleware(application, cas_root_url = config.CAS_SERVICE, logout_url = config.CAS_LOGOUT_PAGE, logout_dest = config.CAS_LOGOUT_DESTINATION, protocol_version = config.CAS_VERSION, casfailed_url = config.CAS_FAILURE_PAGE, entry_page = '/static/main.html', session_store = fs_session_store, ignore_redirect = '(.*)\?datatype=', ignored_callback = ignored_callback)<commit_msg>Don't fail if cas not defined in config<commit_after>import wsgi_server
import os
from werkzeug.wsgi import SharedDataMiddleware
import config
from cas import CASMiddleware
import logging
from werkzeug.contrib.sessions import FilesystemSessionStore
from werkzeug.wrappers import Response

#logging.basicConfig(level=logging.DEBUG)

#This function is called if:
# Not authenticated
# the ignore_redirect regex matches the (full) url pattern
def ignored_callback(environ, start_response):
    response = Response('{"Error":"NotAuthenticated"}')
#    response.status = '401 Unauthorized'
    response.status = '200 OK'
    response.headers['Content-Type'] = 'application/json'

    return response(environ, start_response)

application = wsgi_server.application

application = SharedDataMiddleware(application, {
    '/static': os.path.join(os.path.dirname(__file__), 'static')
})

try:
    cas_service = config.CAS_SERVICE
except AttributeError:
    cas_service = ''
if cas_service != '':
  fs_session_store = FilesystemSessionStore()
  application = CASMiddleware(application, cas_root_url = cas_service, logout_url = config.CAS_LOGOUT_PAGE, logout_dest = config.CAS_LOGOUT_DESTINATION, protocol_version = config.CAS_VERSION, casfailed_url = config.CAS_FAILURE_PAGE, entry_page = '/static/main.html', session_store = fs_session_store, ignore_redirect = '(.*)\?datatype=', ignored_callback = ignored_callback)
{'fraction_non_alphanumeric': 0.09720176730486009, 'fraction_numerical': 0.004418262150220913, 'mean_word_length': 6.423497267759563, 'pattern_counts': {'":': 2, '<': 3, '<?xml version=': 0, '>': 3, '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': '1624539', 'n_tokens_mistral': 811, 'n_tokens_neox': 794, 'n_words': 186}