Create a server which serves at port 3000 and with node.js command prompt
// app.js
const http = require('http');
// Create an instance of the http server to handle HTTP requests
let app = http.createServer((req, res) => {
// Set a response type of plain text for the response
res.writeHead(200, {'Content-Type': 'text/plain'});
// Send back a response and end the connection
res.end('Hello World!\n');
});
// Start the server on port 3000
app.listen(3000, '127.0.0.1');
console.log('Node server running on port 3000');
//console
$ node app.js // runs it
//to open it in ur browser, go to http://localhost:3000.
Also in JavaScript:
- in angular click button button hide div and show div
- react image
- scrollspyNav react
- how to edit message discord.js
- chrome add bookmark that prefixes text
- javascript onclick
- convert int to float in javascript
- javascript 1 + "1"
- javascript date format
- how to remove a class from element with javascript
- children array javascript
- how to reset settimeout in javascript
- ctx beginpath react
- jquery check if all checkbox is not checked
- computed setter
- clear a div
- javascript canvas gamma correction
- puppeteer stealth popup
- how to print a line in javascript
- javascript multiplication table
- javascript includes method getting 'hi' and 'high' problem
- calcular sobra de divisão de parcelas js
- add component in angular router
- strict equality