-
Notifications
You must be signed in to change notification settings - Fork 15
/
app.js
26 lines (20 loc) · 775 Bytes
/
app.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
// const ejs = require('ejs')
const express = require('express')
const fs = require('fs')
const path = require('path')
const config = require('../config.json')
// const host = config.host
const port = +process.env.PORT || config.port
const app = express()
app.use(express.static(path.join(__dirname, 'public')))
var filepath = path.join(__dirname, 'Paradise.m4a')
app.get('/music', function (req, res) {
console.log('Returning ' + path.basename(filepath) + ' for request /music')
res.set({ 'Content-Type': 'audio/mpeg' })
var readStream = fs.createReadStream(filepath)
readStream.pipe(res)
})
app.listen(port, function () {
console.log('Module search path: ' + (process.env.NODE_PATH || '(none)'))
console.log('Express server listening on port ' + port)
})