0

I have set up Apache web server to proxy node applications in a virtualhost environment.

I have an express application that serves a static web page:

app.use(express.static('.'))
app.set('views', path.join(__dirname, 'views'));
app.set('view engine', 'pug')

function getMySQLConnection() {
        return mysql.createConnection({
          host     : 'localhost',
          user     : 'root',
          password : 'pwd',
          database : 'Persons'
        });
}

app.get('/', function(req, res) {
        res.sendFile(path.join(__dirname + '/mainpage.html'));
});

app.get('/OnAcceptTerms', function(req, res) {
   ...
});

app.listen(8066);

The mainpage.html file is just a page that forces the user to accept terms. There is a checkbox that says he accepts terms, and then a button becomes active that allows him to proceed.

<body onload="disableSubmit()">
 <input type="checkbox" name="terms" id="terms" onchange="activateButton(this)">  I Agree Terms & Coditions
  <br><br>
  <input type="button" name="submit" id="submit" value="Enter" onclick=window.location.assign('http://www.google.com')>
</center>

In the onclick= method, how do I would like to pass control back to express so that

app.get('/OnAcceptTerms',

code gets executed when the user clicks the button on the static web page?

Ivan
  • 7,448
  • 14
  • 69
  • 134

1 Answers1

2

It sounds like all you need is to redirect the web browser to /OnAcceptTerms. You can do this with a button.

<form action="/OnAcceptTerms" method="get">
    <input type="submit" value="Accept Terms" />
</form>

With JavaScript (e.g., in an onclick handler) you can simply set window.location.

window.location.href = '/OnAcceptTerms';
TypeIA
  • 16,916
  • 1
  • 38
  • 52