Skip to content

Instantly share code, notes, and snippets.

@SubhashiniSundaresan
Last active April 25, 2019 12:51
Show Gist options
  • Save SubhashiniSundaresan/13d52d6774465c3b7790fe6cd5fb5775 to your computer and use it in GitHub Desktop.
Save SubhashiniSundaresan/13d52d6774465c3b7790fe6cd5fb5775 to your computer and use it in GitHub Desktop.

Revisions

  1. SubhashiniSundaresan revised this gist Apr 25, 2019. 1 changed file with 20 additions and 0 deletions.
    20 changes: 20 additions & 0 deletions express index.html 2
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,20 @@
    npm install -s express
    npm install -s morgan chalk
    npm install nodemon -g

    const light = require('tp-link-api-cloud');
    //Requires
    const express = require('express');
    const app = express();
    const path = require('path');
    const chalk = require('chalk');
    const morgan = require('morgan');
    //Static Routes
    app.use('/dist', express.static(path.join(__dirname, 'dist')));
    app.use(morgan('dev')) // logging
    //Main App Route
    app.get('/', (req, res, next) => res.sendFile(path.join(__dirname, 'dist/index.html')));
    app.get('/start', (req, res, next) => {light.lightbulb(req.params.brightness)}
    const port = 1337;
    //Run Server
    app.listen(process.env.PORT || port, () => console.log(chalk.blue(`Listening intently on port ${port}`)));
  2. SubhashiniSundaresan created this gist Mar 27, 2019.
    19 changes: 19 additions & 0 deletions express index.html
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,19 @@
    npm install -s express
    npm install -s morgan chalk
    npm install nodemon -g


    //Requires
    const express = require('express');
    const app = express();
    const path = require('path');
    const chalk = require('chalk');
    const morgan = require('morgan');
    //Static Routes
    app.use('/dist', express.static(path.join(__dirname, 'dist')));
    app.use(morgan('dev')) // logging
    //Main App Route
    app.get('/', (req, res, next) => res.sendFile(path.join(__dirname, 'dist/index.html')));
    const port = 1337;
    //Run Server
    app.listen(process.env.PORT || port, () => console.log(chalk.blue(`Listening intently on port ${port}`)));