Data & Configuration

Built-in data management, environment variables, and configuration options.

Environment Variables

Access environment variables in templates using syntax. Perfect for API keys, configuration, and secrets.

Live Examples:

USER:

HOME: /home/wwwhat

SHELL:

Tip: Set variables when starting the server:
API_KEY=secret DEBUG=true cargo run -- dev
<p>API Key: </p> <p>Debug: </p> <p>Database: </p>

Data Store

What includes a built-in JSON data store. Define collections in wwwhat.toml or use the data/ directory.

Configuration:
# wwwhat.toml
[data]
posts = { file = "data/posts.json" }
users = { file = "data/users.json" }
Template Usage:
<loop data="#posts#" as="post">
  <h2>#post.title#</h2>
</loop>
# wwwhat.toml configuration [data] posts = { file = "data/posts.json", cache = 60 } users = { file = "data/users.json", cache = 300 } # Using in templates <loop data="#posts#" as="post"> <h2>#post.title#</h2> <p>#post.excerpt#</p> </loop>

CRUD Operations

Built-in endpoints for create, update, and delete operations on your data collections.

Create
POST /w-action/posts?w-action=create&w-redirect=/posts
Update
POST /w-action/posts/123?w-action=update&w-redirect=/posts
Delete
POST /w-action/posts/123?w-action=delete&w-redirect=/posts
<!-- Create form --> <form action="/w-action/posts?w-action=create&w-redirect=/posts"> <input name="title"> <button type="submit">Create</button> </form> <!-- Update form --> <form action="/w-action/posts/#id#?w-action=update"> <input name="title" value="#post.title#"> <button type="submit">Update</button> </form> <!-- Delete button --> <form action="/w-action/posts/#id#?w-action=delete"> <button type="submit">Delete</button> </form>

Caching

What includes multi-level caching for optimal performance with automatic invalidation.

Cache Levels:
  • Page cache: Rendered HTML pages
  • Data cache: JSON file contents
  • External cache: API responses

Cache is automatically invalidated when data is modified via w-action endpoints.

# wwwhat.toml [cache] enabled = true ttl = 300 # 5 minutes default # Per-collection cache TTL [data] posts = { file = "data/posts.json", cache = 60 } users = { file = "data/users.json", cache = 300 }

File-Based Routing

Your file structure defines your URLs. No route configuration needed.

pages/
  index.html → /
  about.html → /about
  post/[id].html → /post/123
  blog/index.html → /blog
  404.html → (fallback)
# Dynamic routes with [param] pages/ post/[id].html → /post/123 user/[username].html → /user/john # Access params in templates <h1>Post #id#</h1> <h1>User: #username#</h1>