My goal is to display a website which gives users a menu, then from there
they click on what functionality they want to run, and then node runs a
command on the back end on a ubuntu server using "exec" then displaying the
results to the webpage. So far I have two files, a nodejs file and an html
page
var http = require('http'),
exec = require('child_process').exec,
fs = require('fs') ;
function onRequest(req, res) {
res.writeHead(200, {'Content-Type': 'text/html'});
fs.readFile('form.html', function(err, data){
if(err)
{
res.write("err.message");
}
else
{
res.write(data);
res.end();
}
});
}
var server = http.createServer(onRequest);
server.listen(80, '0.0.0.0');
console.log("Server Running");
My goal is to display a website which gives users a menu, then from there
they click on what functionality they want to run, and then node runs a
command on the back end on a ubuntu server using "exec" then displaying the
results to the webpage. So far I have two files, a nodejs file and an html
page
var http = require('http'),
exec = require('child_process').exec,
fs = require('fs') ;
function onRequest(req, res) {
res.writeHead(200, {'Content-Type': 'text/html'});
fs.readFile('form.html', function(err, data){
if(err)
{
res.write("err.message");
}
else
{
res.write(data);
res.end();
}
});
}
var server = http.createServer(onRequest);
server.listen(80, '0.0.0.0');
console.log("Server Running");
then the form.html
<!DOCTYPE html>
<html>
<body>
<form>
Please select from the following options:
<select id="mySelect">
<option value="apps">Insert all Apps belonging to a group</option>
<option value="groups">Insert groups in databse</option>
<option value="database">Refresh database group table</option>
<option value="another">Add all app from one group to another</option>
<option value="id">Get Group ID</option>
<option value="user">Get User ID</option>
<option value="list">Get list of all apps</option>
</select>
</form>
<p>Click the button to change the selected fruit to banana.</p>
<button type="button" onclick="myFunction()">Try it</button>
<script>
function myFunction() {
if(document.getElementById("mySelect").value = "apps")
{
//do something and display results to webpage
}
else
{
//display error
}
}
</script>
</body>
</html>
My question is, is this the right way of carrying out this task? and if
so,should I export the onRequest function which would then allow me to
display what I want to the webpage with res.write ?
--
Job board: http://jobs.nodejs.org/
New group rules:
https://gist.github.com/othiym23/9886289#file-moderation-policy-md
Old group rules:
https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines
---
You received this message because you are subscribed to the Google Groups
"nodejs" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/nodejs/6ccd25d6-d2a8-4735-8149-8954cc382078%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.