Static File Serving
🗂️ Static File Serving
Section titled “🗂️ Static File Serving”Zuno includes built-in support for serving static files—perfect for delivering frontend assets, documentation, or public resources like images and stylesheets.
📁 Serving a Public Directory
Section titled “📁 Serving a Public Directory”To serve a folder (e.g. public/
) as static content, use the staticFiles()
middleware:
app.use(staticFiles("public"));
This will make all files inside public/
accessible via HTTP:
public/├── index.html├── styles.css└── images/ └── logo.png
/index.html
→http://localhost:3000/index.html
/images/logo.png
→http://localhost:3000/images/logo.png
🧪 Example: Serving a Landing Page
Section titled “🧪 Example: Serving a Landing Page”#include <zuno/zuno.hpp>
int main() {zuno::App app;
// Serve static files from the "public" folderapp.use(staticFiles("public"));
app.listen(3000);}
⚙️ Advanced Options (Coming Soon)
Section titled “⚙️ Advanced Options (Coming Soon)”Future versions of staticFiles()
will support:
- Custom cache headers
- Directory listing toggle
- File extension fallbacks (e.g.
.html
)
🧭 Best Practices
Section titled “🧭 Best Practices”- Place only public assets in the static folder
- Avoid exposing sensitive files (e.g.
.env
,.git
) - Use a CDN for large or high-traffic assets in production
🧭 Next Steps
Section titled “🧭 Next Steps”Now that you can serve static content, explore:
Zuno makes it easy to blend backend logic with frontend delivery—all in modern C++.