valtownGeocities
Val Town is a collaborative website to build and scale JavaScript apps.
Deploy APIs, crons, & store data β all from the browser, and deployed in milliseconds.
Viewing readonly version of main branch: v39View latest version
A modernized custom website publisher that allows you to store and serve HTML websites via Val Town. Originally designed to work with Glif for AI-generated websites, but now supports any HTML content!
- π Large HTML Support: Now handles very large HTML files (up to 10MB)
- π‘οΈ Better Error Handling: Comprehensive validation and user-friendly error messages
- π§ Improved API: RESTful design with proper HTTP status codes
- π Enhanced Data Storage: Tracks creation/update times and file sizes
- π Security: Key validation to prevent malicious inputs
- π Legacy Compatibility: Maintains backward compatibility with existing URLs
- π Bug Fixes: Fixed the
[object Object]display issue
# POST HTML content directly curl -X POST "https://your-val-url.web.val.run/?key=my-site" \ -H "Content-Type: text/html" \ -d "<html><body><h1>Hello World!</h1></body></html>" # POST JSON with HTML (legacy format) curl -X POST "https://your-val-url.web.val.run/?key=my-site" \ -H "Content-Type: application/json" \ -d '{"data": "<html><body><h1>Hello World!</h1></body></html>"}'
# View in browser https://your-val-url.web.val.run/?key=my-site # Get JSON response with metadata https://your-val-url.web.val.run/?key=my-site&format=json
| Method | URL Pattern | Description |
|---|---|---|
GET | /?key=<key> | View published website |
POST | /?key=<key> | Publish HTML content |
GET | /?key=<key>&format=json | Get website data as JSON |
GET | / | Admin interface (when no key provided) |
-
key (required for publish/view): Website identifier
- Format: Alphanumeric characters, hyphens, underscores only
- Max length: 100 characters
- Examples:
my-site,blog_2024,test-page-1
-
format (optional): Response format
html(default): Returns rendered HTMLjson: Returns JSON with metadata
Returns the published HTML with a small footer indicating it's hosted by valtownGeocities.
{ "data": { "html": "<html>...</html>", "createdAt": "2025-11-21T14:56:57.968Z", "updatedAt": "2025-11-21T14:56:57.968Z", "size": 2722 } }
- Large File Support: Handle HTML files up to 10MB
- Multiple Input Formats: Accept raw HTML or JSON with
datafield - Automatic Processing: Strips common formatting artifacts (like ```html blocks)
- Metadata Tracking: Automatic creation/update timestamps and size tracking
- Key Validation: Secure key format validation prevents injection attacks
- Size Limits: Prevents abuse with 10MB file size limit
- Input Sanitization: Processes and cleans HTML input
- Better Error Messages: Clear, actionable error responses
- HTTP Status Codes: Proper REST API status codes (400, 413, 500, etc.)
- Legacy Support: Backward compatible with existing integrations
You can still use this with Glif for AI-generated websites:
- Generate: Run a Glif that generates HTML: https://glif.app/@jamiedubs/glifs/clqecfqdd000tc3vk4i208jl3
- Publish: The Glif will POST the generated HTML to your valtownGeocities instance
- View: Access your website at:
https://your-val-url.web.val.run/?key=YOURKEYHERE
[object Object]Display: Fixed the major bug where websites showed[object Object]instead of actual HTML content- Large File Handling: Improved handling of large HTML payloads
- Error Responses: Better error handling and user feedback
- JSON Processing: Fixed JSON input parsing issues
βββ main.tsx # Main application (HTTP trigger)
βββ README.md # This documentation
The modernized version consolidates everything into a single, well-structured file for better maintainability while preserving all functionality.
# Test the modernized version curl -X POST "https://your-val-url.web.val.run/?key=test" \ -H "Content-Type: text/html" \ -d "<!DOCTYPE html><html><head><title>Test</title></head><body><h1>It works!</h1><p>Large HTML support β </p></body></html>" # View the result curl "https://your-val-url.web.val.run/?key=test" # Get JSON metadata curl "https://your-val-url.web.val.run/?key=test&format=json"