xxxxxxxxxx
const express = require('express');
const app = express();
const cors = require('cors');
const port = 4000;
app.use(cors());
app.use(express.json());
app.get("/", (req, res) => {
res.send("Hello");
});
app.listen(port, () => {
console.log(`Server running on http://localhost:${port}`);
});
xxxxxxxxxx
const express = require("express");
const app = express();
const port = 5000;
app.use(express.json());
app.get("/", (req, res) => {
res.send("Hello");
});
app.listen(port, () => {
console.log(`Server running on http://localhost:${port}`);
});
xxxxxxxxxx
import express from "express";
import { dirname } from "path";
import { fileURLToPath } from "url";
// Get the current directory name using the file URL
const __dirname = dirname(fileURLToPath(import.meta.url));
const app = express();
const port = 3000;
app.use(bodyParser.urlencoded({ extended: true }));
app.get("/", (req, res) => {
res.send("Hello");
})
app.listen(port, () => {
console.log(`Server is running on port ${port}`);
});
xxxxxxxxxx
const express = require("express");
const app = express();
const cors = require("cors");
require("dotenv").config();
const port = process.env.PORT || 5000;
// Middleware
app.use(cors());
app.use(express.json());
// Define your routes and business logic here
app.get("/", (req, res) => {
res.send("sports pro academy is running");
});
app.listen(port, () => {
console.log(`sports pro academy is running on port ${port}`);
});