Public
Like
pale-apex-preamble
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: v27View latest version
A replacement for a simple express app that accepts a URL on its / endpoint
and returns the page's source code to the requesting browser.
- Added as a test and to replace a similar application formerly hosted at glitch.
- Moved main app away from express and implemented an
HTTP Typeval.
# Start local development server ./dev.sh local # or deno task local-dev # Deploy to Val Town ./dev.sh push # or deno task push
./dev.sh dev- Start Val Town development server./dev.sh local- Start local development server (port 3001)./dev.sh push- Format, check, and deploy to Val Town./dev.sh status- Check project status./dev.sh logs- View logs./dev.sh help- Show all commands
Test locally: http://localhost:3001?url=https://example.com
- The
/endpoint with no parameters shows a simple HTML form for entering a URL - When provided with a
urlquery parameter, it returns the source code of that page as plain text - Includes URL validation and error handling
- Migrated from Express.js to Val Town HTTP handler format
The original Express app was a simple form that accepted a URL and returned the source code. The new implementation:
- Provides a more user-friendly HTML form when no URL is provided
- Validates the URL format before attempting to fetch
- Returns the source as plain text for easy viewing
- Handles errors gracefully with appropriate status codes
GET /?url=https://example.com
Returns: The source code of the specified URL as plain text