Skip to content

Commit dbc879a

Browse files
get request parameters
0 parents  commit dbc879a

File tree

2 files changed

+33
-0
lines changed

2 files changed

+33
-0
lines changed

README.md

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
2+
,-----.,--. ,--. ,---. ,--.,------. ,------.
3+
' .--./| | ,---. ,--.,--. ,-| || o \ | || .-. \ | .---'
4+
| | | || .-. || || |' .-. |`..' | | || | \ :| `--,
5+
' '--'\| |' '-' '' '' '\ `-' | .' / | || '--' /| `---.
6+
`-----'`--' `---' `----' `---' `--' `--'`-------' `------'
7+
-----------------------------------------------------------------
8+
9+
10+
Welcome to your Node.js project on Cloud9 IDE!
11+
12+
This chat example showcases how to use `socket.io` with a static `express` server.
13+
14+
## Running the server
15+
16+
1) Open `server.js` and start the app by clicking on the "Run" button in the top menu.
17+
18+
2) Alternatively you can launch the app from the Terminal:
19+
20+
$ node server.js
21+
22+
Once the server is running, open the project in the shape of 'https://projectname-username.c9.io/'. As you enter your name, watch the Users list (on the left) update. Once you press Enter or Send, the message is shared with all connected clients.

server.js

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
var express=require('express');
2+
var app=express();
3+
app.get('/',function(req,res)
4+
{
5+
console.log(req.headers);
6+
var regex=/\(([^)]+)\)/g;
7+
var headers={'ipaddress':req.headers["x-forwarded-for"],
8+
'language':req.headers['accept-language'],'software':regex.exec(req.headers['user-agent'])[1]};
9+
res.send(JSON.stringify(headers));
10+
});
11+
app.listen(8080);

0 commit comments

Comments
 (0)