<commit_before>#!/usr/bin/env python3

import config as config_module
import lib.blag as blag

for item in dir(config_module):
    if item[0] != "_":
        print("=== Config ===")
        for key in (key for key in dir(config_module) if key[0] != "_"):
            blag.app.config[key] = getattr(config_module, key)
            print(key, "=", getattr(config_module, key))
        print("===+------+===")
        break

from lib.blag.rest import app


@app.route("/")
def get_index():
    with open("static/index.html") as index_file:
        return index_file.read()


if __name__ == '__main__':
    from tornado.httpserver import HTTPServer
    from tornado.ioloop import IOLoop
    from tornado.wsgi import WSGIContainer
    from tornado.web import Application, RequestHandler

    # placeholder for TLS


    class IndexHandler(RequestHandler):
        def get(self):
            with open('./static/index.html') as index_file:
                return self.write(index_file.read())

    http_server = HTTPServer(
        Application(
            [
                (r'^/api', WSGIContainer(app)),
                (r'^/$', IndexHandler),
            ],
            static_path='./static'))

    http_server.listen(**{  # replace with .bind() .start()
        option: app.config[option]<commit_msg>__main__.py: Fix Tornado routing<commit_after>#!/usr/bin/env python3

import config as config_module
import lib.blag as blag

for item in dir(config_module):
    if item[0] != "_":
        print("=== Config ===")
        for key in (key for key in dir(config_module) if key[0] != "_"):
            blag.app.config[key] = getattr(config_module, key)
            print(key, "=", getattr(config_module, key))
        print("===+------+===")
        break

from lib.blag.rest import app


@app.route("/")
def get_index():
    with open("static/index.html") as index_file:
        return index_file.read()


if __name__ == '__main__':
    from tornado.httpserver import HTTPServer
    from tornado.ioloop import IOLoop
    from tornado.wsgi import WSGIContainer
    from tornado.web import Application, RequestHandler, FallbackHandler

    # placeholder for TLS

    class IndexHandler(RequestHandler):
        def get(self):
            with open('./static/index.html') as index_file:
                return self.write(index_file.read())

    http_server = HTTPServer(
        Application(
            [
                (r'^/$', IndexHandler),
                (r'^.*', FallbackHandler, {
                    'fallback': WSGIContainer(app)
                }),
            ],
            static_path='./static'))

    http_server.listen(**{  # replace with .bind() .start()
        option: app.config[option]
{'fraction_non_alphanumeric': 0.13545521835677277, 'fraction_numerical': 0.0022205773501110288, 'mean_word_length': 2.3329223181257706, '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': '1586528', 'n_tokens_mistral': 828, 'n_tokens_neox': 797, 'n_words': 199}