Blame view

node_modules/videojs-contrib-media-sources/scripts/server.js 705 Bytes
2a09d1a4   liuqimichale   添加宜春 天水 宣化
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
27
28
29
30
31
32
33
34
  import connect from 'connect';
  import cowsay from 'cowsay';
  import path from 'path';
  import portscanner from 'portscanner';
  import serveStatic from 'serve-static';
  
  // Configuration for the server.
  const PORT = 9999;
  const MAX_PORT = PORT + 100;
  const HOST = '127.0.0.1';
  
  const app = connect();
  
  const verbs = [
    'Chewing the cud',
    'Grazing',
    'Mooing',
    'Lowing',
    'Churning the cream'
  ];
  
  app.use(serveStatic(path.join(__dirname, '..')));
  
  portscanner.findAPortNotInUse(PORT, MAX_PORT, HOST, (error, port) => {
    if (error) {
      throw error;
    }
  
    process.stdout.write(cowsay.say({
      text: `${verbs[Math.floor(Math.random() * 5)]} on ${HOST}:${port}`
    }) + '\n\n');
  
    app.listen(port);
  });