Created
June 24, 2015 08:10
-
-
Save nikezono/253d87defb3f3e91c89c to your computer and use it in GitHub Desktop.
シンプルな性的ファイル配信サーバ
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # Node.js API | |
| path = require 'path' | |
| fs = require 'fs' | |
| # NPM modules | |
| express = require 'express' | |
| stream = require 'connect-stream' | |
| app = express() | |
| # Config | |
| loadPath = process.env.STATIC_FILE_PATH || 'statics' | |
| app.use(stream(path.resolve(loadPath))) | |
| app.set('view engine', 'jade') | |
| app.get '/', (req,res)-> | |
| res.render "index", | |
| files: fs.readdirSync(path.resolve loadPath) | |
| app.get '/:filename', (req,res)-> | |
| res.render 'play', | |
| title: req.params.filename | |
| app.get '/:filename/stream', (req,res)-> | |
| res.stream req.params.filename | |
| app.listen process.env.PORT || 3070 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| h1 files | |
| ul | |
| for file in files | |
| li | |
| a(href="/"+file)= file | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| h1= title | |
| video(width="720", height="480", controls) | |
| source(src="/"+title+"/stream") | |
| |ブラウザがvideoタグをサポートしていないです🍣 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment