title: How to use Electron with an existing Express application
body: <p>I read and tried samples like the one on <a href="https://github.com/frankhale/electron-with-express" rel="noreferrer">https://github.com/frankhale/electron-with-express</a> but still I don't understand how to convert an Express app into Electron </p>
  
  <p>How can I use Electron with an existing Express application?</p>
  
  <p>Take for example this Express application:</p>
  
  <p><strong>app.js</strong></p>
  
  <pre><code>var express = require("express");
  var app = express();
  
  var request = require("request");
  
  app.set("view engine", "ejs");
  
  app.get("/", function(req, res) {
      res.render("search");
  });
  
  app.get("/results", function(req, res){
      var query = req.query.search;
      var url = "https://yts.am/api/v2/list_movies.json?sort=seeds&amp;limit=15&amp;query_term='" + query + "'";
      request(url, function(error, response, body){
          var data = JSON.parse(body);
          if(!error &amp;&amp; response.statusCode == 200){
              //res.send(data["data"]["movies"][0]["title"]);
              res.render("results", {data: data});
              //["movies"][0]["title"]
          }
          else
          console.log(data);
      });
  });
  
  app.listen(process.env.PORT, process.env.IP, function(){
      console.log("IMDB server has started");
  });
  </code></pre>
  
  <p><strong>search.ejs</strong></p>
  
  <pre><code>Search for a movie
  
  &lt;form action="results" method="GET"&gt;
      &lt;input type="text" placeholder="search term" name="search"&gt;
      &lt;input type="submit"&gt;
  &lt;/form&gt;
  </code></pre>
  
  <p><strong>results.ejs</strong></p>
  
  <pre><code>Results page
  &lt;ul&gt;
      &lt;% data["data"]["movies"].forEach(function(movie){ %&gt;
          &lt;li&gt;
              &lt;strong&gt;&lt;%= movie["title"]%&gt;&lt;/strong&gt; - &lt;%= movie["year"]%&gt;
          &lt;/li&gt;
      &lt;% }) %&gt;
  &lt;/ul&gt;
  
  &lt;a href="/"&gt;Search again&lt;/a&gt;
  </code></pre>