Data & Configuration
Environment Variables
Access environment variables in templates using syntax.
Perfect for API keys, configuration, and secrets.
Live Examples
USER:
HOME: /home/wwwhat
SHELL:
<p>API Key: </p>
<p>Debug: </p>
Tip: Set variables when starting the server:
API_KEY=secret DEBUG=true cargo run -- dev
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", 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.
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
Caching
What includes multi-level caching for optimal performance.
Cache Levels
- Page cache: Rendered HTML pages
- Data cache: JSON file contents with configurable TTL
- External cache: API responses from external URLs
Configuration
# wwwhat.toml
[cache]
enabled = true
ttl = 300 # 5 minutes default
Cache Invalidation
Cache is automatically invalidated when data is modified via
w-action endpoints.
File-Based Routing
Your file structure defines your URLs.
pages/
index.html → /
about.html → /about
post/[id].html → /post/123
blog/index.html → /blog
404.html → (fallback)
index.html → /
about.html → /about
post/[id].html → /post/123
blog/index.html → /blog
404.html → (fallback)