// this is your code
// ZDev1#4511 on discord if you want more help!
// first you should install express in the terminal
// `npm i express`.
const express = require('express');
const app = express();
// route
app.get('/', (req,res)=>{
// Sending This is the home page! in the page
res.send('This is the home page!');
});
// Listening to the port
let PORT = 3000;
app.listen(PORT)
// FINISH!
const express = require("express");
const cors = require("cors");
require("dotenv").config();
const port = process.env.PORT || 5000;
const app = express();
//middle ware
app.use(cors());
app.use(express.json());
app.get("/", (req, res) => {
res.send("server is up");
});
app.listen(port, () => {
console.log("server is running");
});
const express = require("express")
const app = express()
app.listen(5000, () => {
console.log("Server has started!")
})
const express = require('express');
const app = express();
const mongoose = require('mongoose');
const bodyParser = require('body-parser');
app.use(bodyParser.json());
const PORT = process.env.PORT || 3000;
app.use(bodyParser.json());
//connecting to db
try {
mongoose.connect('mongodb://localhost/YOUR_DB_NAME', {
useNewUrlParser: true,
useUnifiedTopology: true,
useCreateIndex: true,
}, () =>
console.log("connected"));
} catch (error) {
console.log("could not connect");
}
app.get('/', (req, res) => {
res.send('<h1>Some HTML</h1>');
res.send('<p>Even more HTML</p>');
});
app.listen(PORT, () => console.log(`Server is listening on port ${PORT}`));
const express = require('express')
const app = express()
const port = 9000
app.get('/',(req,res) => {
try {
res.json({message:"server is ready at 9000 port "})
} catch (error) {
consolelog(error)
res.sendStatus(500)
}
})
app.listen(port,() => console.log('server is runing at 9000'))