<commit_before># -*- coding=utf -*-
from .blueprint import slicer
from flask import Flask
import ConfigParser

from .utils import *

__all__ = (
    "create_server",
    "run_server",
)

# Server Instantiation and Running
# ================================

def _read_config(config):
    if isinstance(config, basestring):
        try:
            path = config
            config = ConfigParser.SafeConfigParser()
            config.read(path)
        except Exception as e:
            raise Exception("Unable to load configuration: %s" % e)
    return config

def create_server(config):
    """Returns a Flask server application. `config` is a path to a
    ``slicer.ini`` file with Cubes workspace and server configuration."""

    config = _read_config(config)
    app = Flask("slicer")
    app.register_blueprint(slicer, config=config)

    return app


def run_server(config, debug=False):
    """Run OLAP server with configuration specified in `config`"""

    config = _read_config(config)
    app = create_server(config)

    if config.has_option("server", "host"):
        host = config.get("server", "host")
    else:
        host = "localhost"

    if config.has_option("server", "port"):
        port = config.getint("server", "port")
    else:
        port = 5000<commit_msg>Create_server does not need a config<commit_after># -*- coding=utf -*-
from .blueprint import slicer
from flask import Flask
import ConfigParser

from .utils import *

__all__ = (
    "create_server",
    "run_server",
)

# Server Instantiation and Running
# ================================

def _read_config(config):
    if not config:
        return ConfigParser.SafeConfigParser()
    elif isinstance(config, basestring):
        try:
            path = config
            config = ConfigParser.SafeConfigParser()
            config.read(path)
        except Exception as e:
            raise Exception("Unable to load configuration: %s" % e)
    return config

def create_server(config=None):
    """Returns a Flask server application. `config` is a path to a
    ``slicer.ini`` file with Cubes workspace and server configuration."""

    config = _read_config(config)
    app = Flask("slicer")
    app.register_blueprint(slicer, config=config)

    return app


def run_server(config, debug=False):
    """Run OLAP server with configuration specified in `config`"""

    config = _read_config(config)
    app = create_server(config)

    if config.has_option("server", "host"):
        host = config.get("server", "host")
    else:
        host = "localhost"

    if config.has_option("server", "port"):
        port = config.getint("server", "port")
    else:
        port = 5000
{'fraction_non_alphanumeric': 0.1311659192825112, 'fraction_numerical': 0.0029895366218236174, 'mean_word_length': 3.0438066465256797, 'pattern_counts': {'":': 0, '<': 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': '1315453', 'n_tokens_mistral': 780, 'n_tokens_neox': 753, 'n_words': 225}