docs.pyserve.org/guides/configuration.html
Илья Глазунов 00119ce463
All checks were successful
Deploy to Production / deploy (push) Successful in 5s
Refactor documentation for reverse proxy and routing guides
2025-12-08 01:05:52 +03:00

183 lines
5.6 KiB
HTML

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Configuration - pyserve</title>
<link rel="stylesheet" href="../style.css">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/11.9.0/styles/github-dark.min.css">
<script src="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/11.9.0/highlight.min.js"></script>
<script>hljs.highlightAll();</script>
</head>
<body>
<div id="container">
<div id="header">
<h1>pyserve</h1>
<div class="tagline">python application orchestrator</div>
</div>
<div class="breadcrumb">
<a href="../index.html">Home</a> / <a href="index.html">Guides</a> / Configuration
</div>
<div id="content">
<h2>Configuration Reference</h2>
<p>pyserve uses YAML configuration files. By default, it looks for
<code>config.yaml</code> in the current directory.</p>
<h3>http</h3>
<p>HTTP-related paths configuration.</p>
<dl>
<dt>static_dir</dt>
<dd>Path to static files directory. Default: <code>./static</code></dd>
<dt>templates_dir</dt>
<dd>Path to templates directory. Default: <code>./templates</code></dd>
</dl>
<h3>server</h3>
<p>Core server settings.</p>
<dl>
<dt>host</dt>
<dd>Bind address. Default: <code>0.0.0.0</code></dd>
<dt>port</dt>
<dd>Listen port. Default: <code>8080</code></dd>
<dt>backlog</dt>
<dd>Connection queue size. Default: <code>5</code></dd>
<dt>default_root</dt>
<dd>Enable default root handler. Default: <code>false</code></dd>
<dt>proxy_timeout</dt>
<dd>Default timeout for proxy requests in seconds. Default: <code>30.0</code></dd>
<dt>redirect_instructions</dt>
<dd>Dictionary of redirect rules. Format: <code>"/from": "/to"</code></dd>
</dl>
<h3>ssl</h3>
<p>SSL/TLS configuration for HTTPS.</p>
<dl>
<dt>enabled</dt>
<dd>Enable HTTPS. Default: <code>false</code></dd>
<dt>cert_file</dt>
<dd>Path to SSL certificate file. Default: <code>./ssl/cert.pem</code></dd>
<dt>key_file</dt>
<dd>Path to SSL private key file. Default: <code>./ssl/key.pem</code></dd>
</dl>
<h3>logging</h3>
<p>Logging configuration with structlog support.</p>
<dl>
<dt>level</dt>
<dd>Log level: <code>DEBUG</code>, <code>INFO</code>, <code>WARNING</code>,
<code>ERROR</code>. Default: <code>INFO</code></dd>
<dt>console_output</dt>
<dd>Output to console. Default: <code>true</code></dd>
<dt>format</dt>
<dd>Format configuration object (see below)</dd>
<dt>console</dt>
<dd>Console handler configuration</dd>
<dt>files</dt>
<dd>List of file handlers for logging to files</dd>
</dl>
<h4>logging.format</h4>
<dl>
<dt>type</dt>
<dd>Format type: <code>standard</code> or <code>json</code>. Default: <code>standard</code></dd>
<dt>use_colors</dt>
<dd>Enable colored output in console. Default: <code>true</code></dd>
<dt>show_module</dt>
<dd>Show module name in logs. Default: <code>true</code></dd>
<dt>timestamp_format</dt>
<dd>Timestamp format string. Default: <code>%Y-%m-%d %H:%M:%S</code></dd>
</dl>
<h4>logging.files[]</h4>
<dl>
<dt>path</dt>
<dd>Path to log file</dd>
<dt>level</dt>
<dd>Log level for this file handler</dd>
<dt>format</dt>
<dd>Format configuration for this file</dd>
<dt>loggers</dt>
<dd>List of logger names to include (empty = all loggers)</dd>
<dt>max_bytes</dt>
<dd>Maximum file size before rotation. Default: <code>10485760</code> (10MB)</dd>
<dt>backup_count</dt>
<dd>Number of backup files to keep. Default: <code>5</code></dd>
</dl>
<h3>extensions</h3>
<p>List of extension modules to load. See <a href="../reference/extensions.html">Extensions Reference</a>.</p>
<h3>Complete Example</h3>
<pre><code class="language-yaml">http:
static_dir: ./static
templates_dir: ./templates
server:
host: 0.0.0.0
port: 8080
backlog: 5
default_root: false
proxy_timeout: 30.0
ssl:
enabled: false
cert_file: ./ssl/cert.pem
key_file: ./ssl/key.pem
logging:
level: INFO
console_output: true
format:
type: standard
use_colors: true
timestamp_format: "%Y-%m-%d %H:%M:%S"
files:
- path: ./logs/pyserve.log
level: DEBUG
max_bytes: 10485760
backup_count: 5
extensions:
- type: routing
config:
regex_locations:
"__default__":
root: "./static"
index_file: "index.html"</code></pre>
<div class="warning">
<strong>Warning:</strong> When running in production, always use SSL
and restrict the bind address appropriately.
</div>
</div>
<div id="footer">
<p>pyserve &copy; 2024-2025 | MIT License</p>
</div>
</div>
</body>
</html>