1const express = require('express')
2const app = express()
3const port = 3000
4
5app.get('/', (req, res) => res.send('Hello World!'))
6
7app.listen(port, () => console.log(`Example app listening at http://localhost:${port}`))
1import express from 'express';
2const server = express();
3
4const port = 8080;
5
6server.get('/', (req, res) => {
7 return res.send('Hello, Express.js!');
8})
9
10server.listen(port, () => {
11 console.log(`Server is running on port ${port}`);
12});
1require('dotenv').config();
2
3const express = require('express');
4const server = express();
5const cors = require('cors');
6const ejs = require('ejs');
7const methodOverride = require('method-override');
8const pg = require('pg');
9const agent = require('superagent');
10
11const client = new pg.Client(process.env.DATABASE_URL);
12
13server.use(methodOverride('_method'));
14server.use(express.static('./public'));
15server.use(cors());
16server.use(express.urlencoded({extended :true}));
17server.set('view engine','ejs');
1const http = require('http');
2
3const hostname = '127.0.0.1';
4const port = 3000;
5
6const server = http.createServer((req, res) => {
7 res.statusCode = 200;
8 res.setHeader('Content-Type', 'text/plain');
9 res.end('Hello World');
10});
11
12server.listen(port, hostname, () => {
13 console.log(`Server running at http://${hostname}:${port}/`);
14});
15