<commit_before>Configuration and Options
=========================

See `etc/loris.conf` (or `/etc/loris/loris.conf` after you've run `setup.py install`).

In addition to a bunch of directory paths (items that end with `_dp`) which should be self-explanatory and the [transformation options explained below](#image-transformations), there are some options:

###`[loris.Loris]`

 * `tmp_dp`. A temporary directory that loris can write to. `setup.py` will create this for you.

 * `www_dp`. The destination for the WSGI script. If you change this, it needs to be reflected in the Apache configuration (see [Apache Deployment Notes](apache.md)).

 * `run_as_user` and `run_as_group`. These are the user and group that will own the loris processes. When `setup.py` is run (likely as root or with sudo, everything is adusted to suit this owner.

 * `default_format`. Default format to return when no request format is supplied in the URI (`*.jpg`, `*.png`, etc.) or HTTP `Accept` header. Value is any three character value for a supported format from [Section 4.5](http://goo.gl/3BqIJ) of the spec. Out of the box, `jpg`,`png`, `tif`, and `gif` are supported.

 * `enable_caching`. If `enable_caching=0` no Memory or filesystem caching will happen and `Last-Modified` headers not be sent. This should only be used for testing/development/debugging.

 * `redirect_base_uri` If `redirect_base_uri=1`, when a base URI is dereferenced (i.e. `{scheme}://{server}{/prefix}/{identifier}`) the server will redirect to `{scheme}://{server}{/prefix}/{identifier}/**info.json**` with a `303`. Otherwise the info json is just returned directly. 

 * `redirect_cannonical_image_request` If `redirect_cannonical_image_request=1` and the request for an image is not the cannonical path (e.g. only a width is supplied and the height is calculated by the server), the client will be redirected a `301`.

 * `redirect_conneg` If `redirect_conneg=1` when asking for, e.g., `/info` with `Accept: application/json` (as opposed to the cannonical `/info.json`), the client will be redirected with a `301` to `/info.json`. This also applies to image requests.

 * `enable_cors` / `cors_whitelist` If `enable_cors=1`, the following property, `cors_whitelist` will be read and and the `Origin` header of the request will be checked against that list. If there is a match, the [`Access-Control-Allow-Origin`](http://www.w3.org/TR/cors/#access-control-allow-origin-response-header) will contain that value and the request should go through. **The value of this option can also be set to `*`**, which will make info requests publicly available (responses will include `Access-Control-Allow-Origin=*`)

 Note that you can also supply a `callback` parameter to requests (e.g. `?callback=myfunct`) to do [JSONP](http://en.wikipedia.org/wiki/JSONP) style requests. (This is not part of the IIIF API and may not work--probably will not--work with on other implementations.

### `[logging]`

Each module has its own logger and is chock-full of debug statements, so setting the level to to `INFO` or higher is highly recommended. 

The options are fairly self-explanatory; a few pointers
 
 * `log_to`. Can be `file` or `console` If set to `console`, and you're in production behind Apache, statements will go to Apache's logs. `DEBUG` and `INFO` are mapped to stdout, the rest to stderr.
 * `log_level`. Can be `DEBUG`, `INFO`, `WARNING`, `ERROR`, or `CRITICAL`

 The rest only matter if `log_to=file`:

 * `log_dir`. This MUST exist and be writable. `setup.py` will take care of this,
 but it's your responsibility if you make changes once deployed.
 * `max_size`. Is in bytes, e.g. 5242880 == 5 MB
 * `max_backups`. This many previous logs will be kept.
 * `format`. Format of the log entries. See [Python LogRecord attributes](http://docs.python.org/2/library/logging.html#logrecord-attributes) for options.

### `[resolver.Resolver]`

Any options you add here will be passed through to the resolver you implement. For an explanation of the default resolver, see the [Resolver page](resolver.md).<commit_msg>bold doesn't work with preformat<commit_after>Configuration and Options
=========================

See `etc/loris.conf` (or `/etc/loris/loris.conf` after you've run `setup.py install`).

In addition to a bunch of directory paths (items that end with `_dp`) which should be self-explanatory and the [transformation options explained below](#image-transformations), there are some options:

###`[loris.Loris]`

 * `tmp_dp`. A temporary directory that loris can write to. `setup.py` will create this for you.

 * `www_dp`. The destination for the WSGI script. If you change this, it needs to be reflected in the Apache configuration (see [Apache Deployment Notes](apache.md)).

 * `run_as_user` and `run_as_group`. These are the user and group that will own the loris processes. When `setup.py` is run (likely as root or with sudo, everything is adusted to suit this owner.

 * `default_format`. Default format to return when no request format is supplied in the URI (`*.jpg`, `*.png`, etc.) or HTTP `Accept` header. Value is any three character value for a supported format from [Section 4.5](http://goo.gl/3BqIJ) of the spec. Out of the box, `jpg`,`png`, `tif`, and `gif` are supported.

 * `enable_caching`. If `enable_caching=0` no Memory or filesystem caching will happen and `Last-Modified` headers not be sent. This should only be used for testing/development/debugging.

 * `redirect_base_uri` If `redirect_base_uri=1`, when a base URI is dereferenced (i.e. `{scheme}://{server}{/prefix}/{identifier}`) the server will redirect to `{scheme}://{server}{/prefix}/{identifier}/info.json` with a `303`. Otherwise the info json is just returned directly. 

 * `redirect_cannonical_image_request` If `redirect_cannonical_image_request=1` and the request for an image is not the cannonical path (e.g. only a width is supplied and the height is calculated by the server), the client will be redirected a `301`.

 * `redirect_conneg` If `redirect_conneg=1` when asking for, e.g., `/info` with `Accept: application/json` (as opposed to the cannonical `/info.json`), the client will be redirected with a `301` to `/info.json`. This also applies to image requests.

 * `enable_cors` / `cors_whitelist` If `enable_cors=1`, the following property, `cors_whitelist` will be read and and the `Origin` header of the request will be checked against that list. If there is a match, the [`Access-Control-Allow-Origin`](http://www.w3.org/TR/cors/#access-control-allow-origin-response-header) will contain that value and the request should go through. **The value of this option can also be set to `*`**, which will make info requests publicly available (responses will include `Access-Control-Allow-Origin=*`)

 Note that you can also supply a `callback` parameter to requests (e.g. `?callback=myfunct`) to do [JSONP](http://en.wikipedia.org/wiki/JSONP) style requests. (This is not part of the IIIF API and may not work--probably will not--work with on other implementations.

### `[logging]`

Each module has its own logger and is chock-full of debug statements, so setting the level to to `INFO` or higher is highly recommended. 

The options are fairly self-explanatory; a few pointers
 
 * `log_to`. Can be `file` or `console` If set to `console`, and you're in production behind Apache, statements will go to Apache's logs. `DEBUG` and `INFO` are mapped to stdout, the rest to stderr.
 * `log_level`. Can be `DEBUG`, `INFO`, `WARNING`, `ERROR`, or `CRITICAL`

 The rest only matter if `log_to=file`:

 * `log_dir`. This MUST exist and be writable. `setup.py` will take care of this,
 but it's your responsibility if you make changes once deployed.
 * `max_size`. Is in bytes, e.g. 5242880 == 5 MB
 * `max_backups`. This many previous logs will be kept.
 * `format`. Format of the log entries. See [Python LogRecord attributes](http://docs.python.org/2/library/logging.html#logrecord-attributes) for options.

### `[resolver.Resolver]`

Any options you add here will be passed through to the resolver you implement. For an explanation of the default resolver, see the [Resolver page](resolver.md).
{'fraction_non_alphanumeric': 0.11290915777859507, 'fraction_numerical': 0.0066200809121000365, 'mean_word_length': 4.5610088616223585, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 4, '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': '5354592', 'n_tokens_mistral': 2408, 'n_tokens_neox': 2298, 'n_words': 1071}