Add backend and frontend structure with routing, components, and styling
- Implemented Express server with CORS and dotenv support - Created basic routing with React Router in frontend - Added Admin and Home components with navigation - Integrated MainForm component for user input - Updated package.json and package-lock.json with new dependencies - Styled components using Tailwind CSS and Lucide icons - Added error handling in server - Created initial EJS view for backend
This commit is contained in:
@@ -0,0 +1,26 @@
|
||||
import express from "express";
|
||||
import cors from "cors";
|
||||
import env from "dotenv";
|
||||
env.config();
|
||||
const app = express();
|
||||
const port = 10001;
|
||||
|
||||
app.use(cors());
|
||||
app.use(express.urlencoded({ extended: true }));
|
||||
app.set("view engine", "ejs");
|
||||
app.use(express.json());
|
||||
|
||||
app.get("/", (req, res) => {
|
||||
res.render("index.ejs", { title: port });
|
||||
});
|
||||
|
||||
app.listen(port, () => {
|
||||
console.log(`Server is running on port: ${port}`);
|
||||
});
|
||||
|
||||
// error handling code
|
||||
app.use((err, req, res, next) => {
|
||||
// Log the error stack and send a generic error response
|
||||
console.error(err.stack);
|
||||
res.status(500).send("Something broke!");
|
||||
});
|
||||
|
Reference in New Issue
Block a user