<commit_before>""":mod:`geofront.server` --- Key management service
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

"""
import argparse
import collections.abc
import datetime
import logging
import os
import os.path
import re
import warnings

from flask import Flask, Response, current_app, json, jsonify, request, url_for
from paramiko.rsakey import RSAKey
from waitress import serve
from werkzeug.contrib.cache import BaseCache, SimpleCache
from werkzeug.exceptions import BadRequest, Forbidden, HTTPException, NotFound
from werkzeug.routing import BaseConverter, ValidationError

from .identity import Identity
from .keystore import KeyStore, format_openssh_pubkey, get_key_fingerprint
from .masterkey import (EmptyStoreError, MasterKeyStore, PeriodicalRenewal,
                        renew_master_key)
from .team import AuthenticationError, Team
from .util import typed
from .version import VERSION

__all__ = ('TokenIdConverter', 'app', 'authenticate', 'create_access_token',
           'get_identity', 'get_key_store', 'get_master_key_renewal_interval',
           'get_master_key_store', 'get_remote_set', 'get_team',
           'get_token_store', 'list_keys', 'main', 'main_parser',
           'server_version')<commit_msg>How to run the server using custom WSGI server<commit_after>""":mod:`geofront.server` --- Key management service
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Although Geofront provides :program:`geofront-server`, a CLI to run
the server, it also provides an interface as a WSGI application as well.
Note that there might some limitations like lack of periodical master key
renewal.

First of all, the server need a configuration, there are several ways to
configure it.

:meth:`app.config.from_pyfile() <flask.Config.from_pyfile>`
    If you can freely execute arbitrary Python code before start the server,
    the method is the most straightforward way to configure the server.
    Note that the argument should be an absolute path, because it interprets
    paths relative to the path of Geofront program, not the current
    working directory (CWD).

    There also are other methods as well:

    - :meth:`~flask.Config.from_object()`
    - :meth:`~flask.Config.from_json()`
    - :meth:`~flask.Config.from_envvar()`

:envvar:`GEOFRONT_CONFIG`
    If you can't execute any arbitrary Python code,
    set the :envvar:`GEOFRONT_CONFIG` environment variable.
    It's useful when to use a CLI frontend of the WSGI server e.g.
    :program:`gunicorn`, :program:`waitress-serve`.

    .. code-block:: console

       $ GEOFRONT_CONFIG="/etc/geofront.cfg.py" gunicorn geofront.server:app

Then you can run a Geofront server using your favorite WSGI server.
Pass the following WSGI application object to the server.  It's a documented
endpoint for WSGI:

    :data:`geofront.server:app <app>`
"""
import argparse
import collections.abc
import datetime
import logging
import os
import os.path
import re
import warnings

from flask import Flask, Response, current_app, json, jsonify, request, url_for
from paramiko.rsakey import RSAKey
from waitress import serve
from werkzeug.contrib.cache import BaseCache, SimpleCache
from werkzeug.exceptions import BadRequest, Forbidden, HTTPException, NotFound
from werkzeug.routing import BaseConverter, ValidationError

from .identity import Identity
from .keystore import KeyStore, format_openssh_pubkey, get_key_fingerprint
from .masterkey import (EmptyStoreError, MasterKeyStore, PeriodicalRenewal,
                        renew_master_key)
from .team import AuthenticationError, Team
from .util import typed
from .version import VERSION

__all__ = ('TokenIdConverter', 'app', 'authenticate', 'create_access_token',
           'get_identity', 'get_key_store', 'get_master_key_renewal_interval',
           'get_master_key_store', 'get_remote_set', 'get_team',
           'get_token_store', 'list_keys', 'main', 'main_parser',
           'server_version')
{'fraction_non_alphanumeric': 0.10406091370558376, 'fraction_numerical': 0.0, 'mean_word_length': 4.753284671532847, 'pattern_counts': {'":': 2, '<': 5, '<?xml version=': 0, '>': 5, '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': '7204141', 'n_tokens_mistral': 1126, 'n_tokens_neox': 1079, 'n_words': 382}