---
title: "HTTP Status Code as a Service"
description: "Building a simple HTTP status code service with Node.js. Practical notes and code examples on HTTP Status Code as a Service."
url: "https://h3manth.com/scribe/http-status-code-as-a-service/"
canonical_url: "https://h3manth.com/scribe/http-status-code-as-a-service/"
markdown_url: "https://h3manth.com/scribe/blog/http-status-code-as-a-service.md"
publishDate: "2013-07-22T00:00:00.000Z"
author: "Hemanth HM"
category: "node"
tags: ["node","javascript"]
word_count: 58
reading_time_minutes: 1
x_markdown_tokens: 218
content_signal: "ai-train=yes, search=yes, ai-input=yes"
---

# HTTP Status Code as a Service

> Building a simple HTTP status code service with Node.js. Practical notes and code examples on HTTP Status Code as a Service.

A simple HTTP status service built with Node.js.

```javascript
var http = require('http');
var url = require("url");

http.createServer(function(req, res) {
  res.writeHead(200, {'Content-Type': 'text/plain'});
  
  var url_parts = url.parse(req.url, true);
  var status = url_parts.pathname.replace(/^\/([^\/]*).*$/, '$1');
  
  res.end(
    http.STATUS_CODES[status] || 
    "Undefined status: " + status || 
    "Try /404"
  );
}).listen(process.env.PORT || 5000);
```

Try it: Request `/418` and get `I'm a teapot`!
