Skip to content

Commit

Permalink
complete resolves
Browse files Browse the repository at this point in the history
  • Loading branch information
iamsaziya committed May 12, 2024
2 parents a0ce016 + 2bb17a3 commit 8942ebc
Show file tree
Hide file tree
Showing 5,544 changed files with 429,140 additions and 7,194 deletions.
The diff you're trying to view is too large. We only load the first 3000 changed files.
214 changes: 0 additions & 214 deletions 404.html

This file was deleted.

78 changes: 78 additions & 0 deletions app.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
const express = require('express');
const path = require("path")
const app = express();
const nodemailer = require('nodemailer');
const port = 3000;

app.use(express.static(path.join(__dirname, 'public')));
app.use(express.urlencoded({ extended: true }))
// Define routes


const transporter = nodemailer.createTransport({
service: 'gmail',
auth: {
user: "[email protected]",
pass: "ineedthispassword",
}
});


app.get('/', (req, res) => {
res.sendFile("index.html", { root: path.join(__dirname, 'public') })
});

app.get("/service", (req, res) => {
res.sendFile("service-details.html", { root: path.join(__dirname, 'public') })
})

app.get("/about", (req, res) => {
res.sendFile("about.html", { root: path.join(__dirname, 'public') })
})

app.get("/contact", (req, res) => {
res.sendFile("contact.html", { root: path.join(__dirname, 'public') })
})


app.post('/contact', (req, res) => {
const { name, email, phone, message } = req.body;

// Create email content
const mailOptions = {
from: '[email protected]',
to: '[email protected]', // Your email address where you want to receive contact form submissions
subject: 'New Contact Form Submission',
html: `<p><b>Name:</b></p> ${name} <br>
<p><b>Email:</b></p> ${email} <br>
<p><b>Phone:</b></p> ${phone} <br>
<p><b>Message:</b></p> ${message}`
};

// Send email
transporter.sendMail(mailOptions, (error, info) => {
if (error) {
console.error(error);
res.status(500).send('Error sending message');
} else {
console.log('Email sent: ' + info.response);
res.send('We have received your message and will respond shortly. Thank you for reaching out to us!');
}
});
});


app.get("/blogs", (req, res) => {
res.sendFile("blogs.html", { root: path.join(__dirname, 'public') })
})

app.get("/*", (req, res) => {
// res.redirect("/")

res.sendFile("/", { root: path.join(__dirname, 'public') })
})

// Start the server
app.listen(port, () => {
console.log(`Server is running on http://localhost:${port}`);
});
Loading

0 comments on commit 8942ebc

Please sign in to comment.