Backend

The backend server built with Hono framework providing translation API endpoints.

Endpoints

GET /

Serves the main application HTML page.

GET /api/languages

Returns a list of supported languages for translation.

Response:

{ "languages": [ { "code": "en", "name": "English" }, { "code": "es", "name": "Spanish" }, ... ] }

POST /api/translate

Translates text between languages.

Request:

{ "text": "Hello world", "from": "en", "to": "es" }

Response:

{ "translatedText": "Hola mundo", "detectedLanguage": "en" }

Translation Service

Uses Google Translate's free API endpoint for translations. Supports:

  • Auto-detection of source language
  • Translation between 20+ common languages
  • Error handling for failed translations

Static File Serving

  • Serves frontend files from /frontend/*
  • Serves shared files from /shared/*
  • Uses Val Town's utility functions for proper file serving