javascript - Sending file with nodeJS on apache -


I have setup of Apache (USBbiserserver) and nodes (both latest versions).

I

HTTPD.CONF

  ProxyPodes / Node http: // localhost: 8000 /  

APP.JS

Current code:

  requires the app = ('Express') () ; Var http = Required ('http'); Http.createServer (function (req, res) {res.writeHead (200, {'Content-Type': 'text / plain'}); res.end ('Hello Apache! \ N');}) 8000, 'localhost'); Trying with app.get ('/ node', function (req, res) {rsendfile ('index.html')}} with // app.get ('/');  

INDEX.HTML

   html> html>   & lt; top & gt; & lt ; Title & gt; Socket .io chat & lt; / title & gt; & gt; Style & gt; * {margin: 0; padding: 0; box-size: border-box;} body {font: 13px helvicica , Aerial;} 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;} # Message [List-Style-Type: None; Margin: 0; Padding: 0;} # Message Lead {Padding: 5px 10px; } # Message taken: nth-child (strange) {background: #eee;} & lt; / style & gt; & lt; / head> gt; body & gt; & lt; ul id = "message" & Lt; / ul & gt; & lt; form action = "" & gt; & lt; input id = "m" autocomplete = "off" /> & lt; button & gt; send & lt ; / Button & gt; & Lt; / Form & gt; & Lt; / Body & gt; & Lt; / Html & gt;  

Working with tutorials from socket.js

this index.html does not load because I think in res.end http.creatserver If I save myself, then it is loading forever.

What am I doing wrong? Just following the tutorial from socket.io ()

My node is in JS code / node Is this a problem?

IDEA:

I'm trying to create an app (for phonegap) which can use php and nodejs.

In the app there are some obvious CRUD functions for some things but this should be a chat too. The company asked me to write in the phonegap because we all know that php / js and c # / java are not experienced.

So I searched for a chat and the best solution was to look nod / socket io. This event is driven and fast.

You're mis-using:

Express-App is actually a The object that you can pass to http.createServer () -Method -. This does not keep it parallel.

If you change it like this:

  // remove the original http.createServer; App.get ('/ node', function (rik, ridge) {res.sendfile ('index.html');}); Http.createServer (app) .listen (8000, 'localhost');  

As you can see in the example, you must define the routes before starting the server.


Comments

Popular posts from this blog

sqlite3 - UPDATE a table from the SELECT of another one -

c# - Showing a SelectedItem's Property -

javascript - Render HTML after each iteration in loop -