public | ||
spec | ||
test | ||
views | ||
.rubocop.yml | ||
.ruby-version | ||
app.rb | ||
Containerfile | ||
Gemfile | ||
Gemfile.lock | ||
README.md | ||
responses.yml | ||
TLDR.md |
No as a Service (NaaS) - Multilingual Edition
A Sinatra-based web service that provides creative "no" responses in multiple languages, with full support for all Nordic languages and automatic language detection.
Features
- Multilingual Support: 8 languages including all Nordic languages
- Automatic Language Detection: Via Accept-Language headers and URL parameters
- Dual Format Support: Serves both HTML (for browsers) and JSON (for APIs)
- Random Responses: Returns a random "no" response from curated lists per language
- Modern Styling: Beautiful glassmorphism design with language indicators
- Health Checks: Built-in health check endpoint for monitoring
- Containerized: Ready for deployment with Podman/Docker
Supported Languages
- 🇬🇧 English (
en
) - Default - 🇳🇴 Norwegian (
no
) - Norsk - 🇸🇪 Swedish (
sv
) - Svenska - 🇩🇰 Danish (
da
) - Dansk - 🇮🇸 Icelandic (
is
) - Íslenska - 🇫🇮 Finnish (
fi
) - Suomi - 🇫🇴 Faroese (
fo
) - Føroyskt - 🏔️ Northern Sami (
smi
) - Sámegiella
API Endpoints
GET /
- Returns a random "no" (HTML by default, JSON with Accept header)GET /api/no
- Explicit JSON endpoint with language detectionGET /api/no/:lang
- Get response in specific language (e.g.,/api/no/no
)GET /languages
- List all available languagesGET /health
- Health check endpointGET /*
- Catch-all that returns "no" for any other path
Language Detection
The service automatically detects language preference through:
- URL Parameter:
?lang=no
(highest priority) - Accept-Language Header: Browser language preferences
- Default Fallback: English (
en
)
Language family mapping is supported:
nb
,nn
→no
(Norwegian variants)sv-*
→sv
(Swedish variants)da-*
→da
(Danish variants)- etc.
Usage Examples
HTML (Browser)
# Default language (auto-detected)
curl http://localhost:4567/
# Specific language via parameter
curl http://localhost:4567/?lang=no
# Language via Accept-Language header
curl -H "Accept-Language: sv-SE,sv;q=0.9" http://localhost:4567/
JSON API
# Auto-detected language
curl -H "Accept: application/json" http://localhost:4567/
# Specific language endpoint
curl http://localhost:4567/api/no/is
# With language parameter
curl http://localhost:4567/api/no?lang=fi
# List available languages
curl http://localhost:4567/languages
Sample JSON Responses
Basic Response:
{
"answer": "Absolutt ikke",
"language": "no",
"language_name": "Norsk (Norwegian)",
"timestamp": "2025-06-06T12:00:00Z",
"service": "No as a Service",
"version": "2.0.0"
}
Languages List:
{
"languages": [
{"code": "en", "name": "English"},
{"code": "no", "name": "Norsk (Norwegian)"},
{"code": "sv", "name": "Svenska (Swedish)"}
],
"default": "en",
"timestamp": "2025-06-06T12:00:00Z"
}
Local Development
Prerequisites
- Ruby 3.2+
- Bundler
Setup
# Install dependencies
bundle install
# Run the application
ruby app.rb
# Or use rerun for auto-reload during development
bundle exec rerun ruby app.rb
The application will be available at http://localhost:4567
Container Deployment
Build with Podman
podman build -t naas .
Run with Podman
# Basic run
podman run -p 4567:4567 naas
# Run in background with restart policy
podman run -d --name naas-service -p 4567:4567 --restart=always naas
# Run with custom port
podman run -p 8080:4567 -e PORT=4567 naas
Docker Commands
The same commands work with Docker by replacing podman
with docker
.
Environment Variables
PORT
- Port to bind to (default: 4567)
Health Monitoring
The service includes a health check endpoint at /health
that returns:
{
"status": "healthy",
"languages_loaded": 8,
"timestamp": "2025-06-06T12:00:00Z"
}
File Structure
.
├── app.rb # Main Sinatra application
├── responses.yml # Multilingual response data
├── Gemfile # Ruby dependencies
├── Containerfile # Container build instructions
└── README.md # This file
Adding New Languages
To add a new language, edit responses.yml
:
xx: # Language code
name: "Language Name"
responses:
- "Response 1"
- "Response 2"
# ... more responses
Then optionally add language family mapping in app.rb
if needed.
Nordic Language Features
Each Nordic language includes culturally appropriate expressions:
- Norwegian: "Når kua flyger" (When cows fly)
- Swedish: "När grisar flyger" (When pigs fly)
- Danish: "Når svin flyver" (When pigs fly)
- Icelandic: "Þegar svín fljúga" (When pigs fly)
- Finnish: "Kun lehmät lentää" (When cows fly)
- Faroese: "Tá svín fljúgva" (When pigs fly)
- Northern Sami: "Go vuonji liddjo" (When reindeer fly)
License
This project is released under the MIT License. Perfect for all your multilingual negative response needs!. Feel free to use it for your negative response needs!