cympfh / hello_one_day

URL shorten service

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

vagrea2015-bar-qnl

dependency

  • node (v0.10+)
  • node modules

node modules

npm command resolves all modules

$ pwd
/home/ubuntu/RHDDB7
$ npm install

test

$ npm test

start server

$ pwd
/home/ubuntu/RHDDB7
$ sudo npm start

SIGINT (C-c) kills this.

API usage

This service has two functions.

  • shorten
  • expand (redirect)

shorten

POST to shorten

curl http://${machine-IP}/api/v1/shortenurl \
  -H 'Content-Type: application/json' \
  -d '{"LongUrl": "http://none.jp/"}'

sample response

{"ShortUrl":"http://${machine-IP}/rt","Created":1418455295391,"LongUrl":"http://none.jp/"}%

expand (redirect)

$ curl http://${machine-IP}/rt
<html><body>redirect to http://none.jp/

$ curl -w "%{http_code} " http://${machine-IP}/rt
<html><body>redirect to http://none.jp/308 

Try on your browser.

/DB (debug command)

access to http://${machine-IP}/DB

About

URL shorten service


Languages

Language:JavaScript 88.8%Language:Shell 3.4%Language:CSS 3.4%Language:HTML 2.8%Language:Makefile 1.6%