FeaturesTemplatesShowcaseTownie
AI
BlogDocsPricing
Log inSign up
craigz
craigzpale-apex-preamble
a simple express app
Public
Like
pale-apex-preamble
Home
Code
8
.gitignore
.vtignore
README.md
deno.json
dev.sh
H
index.http.tsx
local-dev.ts
local-form.html
Branches
1
Pull requests
Remixes
History
Environment variables
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.
Sign up now
Code
/
README.md
Code
/
README.md
Search
6/27/2025
README.md

pale-apex-preamble

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 Type val.

Development

Quick Start

# Start local development server ./dev.sh local # or deno task local-dev # Deploy to Val Town ./dev.sh push # or deno task push

Available Commands

  • ./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

Testing

Test locally: http://localhost:3001?url=https://example.com

App Status

  • 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 url query 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

Implementation Notes

The original Express app was a simple form that accepted a URL and returned the source code. The new implementation:

  1. Provides a more user-friendly HTML form when no URL is provided
  2. Validates the URL format before attempting to fetch
  3. Returns the source as plain text for easy viewing
  4. Handles errors gracefully with appropriate status codes

Original Glitch Application

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-fetch to 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
  • 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.

API Usage

GET /?url=https://example.com

Returns: The source code of the specified URL as plain text

Go to top
X (Twitter)
Discord community
GitHub discussions
YouTube channel
Bluesky
Product
FeaturesPricing
Developers
DocsStatusAPI ExamplesNPM Package Examples
Explore
ShowcaseTemplatesNewest ValsTrending ValsNewsletter
Company
AboutBlogCareersBrandhi@val.town
Terms of usePrivacy policyAbuse contact
ยฉ 2025 Val Town, Inc.