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.
index.http.tsx
https://craigz--5e506c2c514d11f09b4ff69ea79377d9.web.val.run
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
- LIVE ON VAL.TOWN: The latest version is deployed and running at val.town/x/craigz/pale-apex-preamble
- 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
The original application (available in the glitch branch) was a Node.js/Express app with:
- Backend: Express.js server (
server.js) with a single GET route that:- Served a static HTML form when no URL parameter was provided
- Used
node-fetchto retrieve and return page source when a URL was provided
- Frontend: Simple HTML form (
views/index.html) with:- Clean, minimal styling (
public/style.css) - Form submission to the same endpoint with URL parameter
- Designed specifically for mobile/iOS use cases where viewing page source is difficult
- Clean, minimal styling (
- Purpose: Created as a mobile-friendly solution for viewing webpage source code
- Hosting: Originally deployed on Glitch.com platform
The Val.town migration maintains the same core functionality while modernizing the implementation to use Deno and Val.town's HTTP handler format.
GET /?url=https://example.com
Returns: The source code of the specified URL as plain text