I've a setup of apache (usbwebserver) and nodejs (both latest versions).
I changed the httpd.conf (as described here https://stackoverflow.com/a/18604082/1112413)
HTTPD.CONF
ProxyPass /node http://localhost:8000/
APP.JS
Current Code:
var app = require('express')();
var http = require('http');
http.createServer(function (req, res) {
res.writeHead(200, {'Content-Type': 'text/plain'});
res.end('Hello Apache!\n');
}).listen(8000, 'localhost');
//Tried with app.get('/') to
app.get('/node', function(req, res){
res.sendfile('index.html');
});
INDEX.HTML
<!doctype html>
<html>
<head>
<title>Socket.IO chat</title>
<style>
* { margin: 0; padding: 0; box-sizing: border-box; }
body { font: 13px Helvetica, Arial; }
form { background: #000; padding: 3px; position: fixed; bottom: 0; width: 100%; }
form input { border: 0; padding: 10px; width: 90%; margin-right: .5%; }
form button { width: 9%; background: rgb(130, 224, 255); border: none; padding: 10px; }
#messages { list-style-type: none; margin: 0; padding: 0; }
#messages li { padding: 5px 10px; }
#messages li:nth-child(odd) { background: #eee; }
</style>
</head>
<body>
<ul id="messages"></ul>
<form action="">
<input id="m" autocomplete="off" /><button>Send</button>
</form>
</body>
</html>
Working with the tutorial from socket.js
It doesn't load the index.html I think because of the res.end
in http.creatserver
.
If I take res.end away it keeps forever loading.
What am I doing wrong? Just following the tutorial from socket.io (http://socket.io/get-started/chat/ )
My node js code is in /Node. is this a problem?
IDEA:
I'm trying to create a app (for phonegap) that can use php and nodejs.
The app has some obvious CRUD functions for some stuff. But it needs to have a chat also. The company asked me to write it in phonegap since we all know php/js and don't have C#/Java experience.
So I went searching for a chat and the best solution seemed nodejs/socket io because it is event driven and fast because of that.