• Earn real money by being active: Hello Guest, earn real money by simply being active on the forum — post quality content, get reactions, and help the community. Once you reach the minimum credit amount, you’ll be able to withdraw your balance directly. Learn how it works.

JavaScript based Web Server

Status
Not open for further replies.

ssmss

New member
User
Joined
Apr 30, 2018
Messages
4
Reputation
0
Reaction score
8
Points
3
Credits
0
‎7 Years of Service‎
80%
NodeJS - Brings the JavaScript language to your OS, as a scripting language.

Link to nodejs:
This link is hidden for visitors. Please Log in or register now.


Running a JavaScript file is similar to the way python does it.

In command shell: node file.js

Or in Linux: ./node file.js

Code:

// content of index.js const http = require('http') const port = 3000 const requestHandler = (request, response) => { console.log(request.url) response.end('Hello Node.js Server!') } const server = http.createServer(requestHandler) server.listen(port, (err) => { if (err) { return console.log('something bad happened', err) } console.log(`server is listening on ${port}`) })

 
Last edited by a moderator:
Status
Not open for further replies.
Back
Top