Skip to content

Commit

Permalink
Merge pull request #4 from maddox/new-routes
Browse files Browse the repository at this point in the history
New Routes
  • Loading branch information
maddox committed Sep 3, 2015
2 parents f47f5df + 3ab4254 commit 7bf3e61
Show file tree
Hide file tree
Showing 3 changed files with 52 additions and 0 deletions.
10 changes: 10 additions & 0 deletions app.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
var fs = require('fs')
var path = require('path')
var util = require('util')
var express = require('express')
var morgan = require('morgan')
Expand All @@ -14,6 +15,7 @@ var harmonyActivityUpdateTimer

var app = express()
app.use(bodyParser.urlencoded({ extended: false }))
app.use(express.static(path.join(__dirname, 'public')));

var logFormat = "'[:date[iso]] - :remote-addr - :method :url :status :response-time ms - :res[content-length]b'"
app.use(morgan(logFormat))
Expand Down Expand Up @@ -92,6 +94,14 @@ function activityByName(activityName){
return activity
}

app.get('/_ping', function(req, res){
res.send('OK');
})

app.get('/', function(req, res){
res.sendfile('index.html');
})

app.get('/activities', function(req, res){
res.json({activities: cachedHarmonyActivities()})
})
Expand Down
Binary file added public/harmony-icon.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
42 changes: 42 additions & 0 deletions public/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Harmony API</title>
<style media="screen">
body { color: #333333; font-family: 'Helvetica Neue', Helvetica, 'Segoe UI', Arial, freesans, sans-serif; margin-top: 25px;}
h1 { text-align: center; }
a { color: #333333; text-decoration: none; }
a:hover { text-decoration: underline; }
.logo { display: block; margin: auto }
.content { margin: 20px 25%; }
.docs { background-color: #f4f4f4; border-radius: 4px; padding: 10px;}
.docs p { padding: 0; margin: 0; line-height: 28px; font-size: 14px; font-family: Consolas, 'Liberation Mono', Menlo, Courier, monospace; }
.docs .method { background-color: #dbdbdb; padding: 4px; border-radius: 2px; margin-right: 4px;}
.docs h2 { margin-bottom: 8px;}
.docs h2:first-child { margin-top: 0;}
.footer { text-align: center; font-size: 12px; margin: 10px 0 50px 0;}
</style>
</head>
<body>
<img class="logo" src="/harmony-icon.png" alt="Harmony" width="256px" />
<div class="content">
<h1>Harmony API</h1>

<div class="docs">
<h2>Info</h2>
<p><span class="method">GET</span> <a href="/status">/status</a></p>
<p><span class="method">GET</span> <a href="/activities">/activities</a></p>

<h2>Control</h2>
<p><span class="method">PUT</span> /off</p>
<p><span class="method">POST</span> /start_activity?activity_name=Watch%20TV</p>
</div>

<div class="footer">
Learn more at <a href="https://github.com/maddox/harmony-api">https://github.com/maddox/harmony-api</a>
</div>
</div>

</body>
</html>

0 comments on commit 7bf3e61

Please sign in to comment.