Configuration Reference

pyserve uses YAML configuration files. By default, it looks for config.yaml in the current directory.

http

HTTP-related paths configuration.

static_dir
Path to static files directory. Default: ./static
templates_dir
Path to templates directory. Default: ./templates

server

Core server settings.

host
Bind address. Default: 0.0.0.0
port
Listen port. Default: 8080
backlog
Connection queue size. Default: 5
default_root
Enable default root handler. Default: false
proxy_timeout
Default timeout for proxy requests in seconds. Default: 30.0
redirect_instructions
Dictionary of redirect rules. Format: "/from": "/to"

ssl

SSL/TLS configuration for HTTPS.

enabled
Enable HTTPS. Default: false
cert_file
Path to SSL certificate file. Default: ./ssl/cert.pem
key_file
Path to SSL private key file. Default: ./ssl/key.pem

logging

Logging configuration with structlog support.

level
Log level: DEBUG, INFO, WARNING, ERROR. Default: INFO
console_output
Output to console. Default: true
format
Format configuration object (see below)
console
Console handler configuration
files
List of file handlers for logging to files

logging.format

type
Format type: standard or json. Default: standard
use_colors
Enable colored output in console. Default: true
show_module
Show module name in logs. Default: true
timestamp_format
Timestamp format string. Default: %Y-%m-%d %H:%M:%S

logging.files[]

path
Path to log file
level
Log level for this file handler
format
Format configuration for this file
loggers
List of logger names to include (empty = all loggers)
max_bytes
Maximum file size before rotation. Default: 10485760 (10MB)
backup_count
Number of backup files to keep. Default: 5

extensions

List of extension modules to load. See Extensions Reference.

Complete Example

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"
Warning: When running in production, always use SSL and restrict the bind address appropriately.