New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
This file contains newsletter-signup page.. #876
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
//jshint esversion:6 | ||
|
||
const express = require("express"); | ||
const bodyParser = require("body-parser"); | ||
const request = require("request"); | ||
const https = require("https"); | ||
|
||
const app = express(); | ||
|
||
app.use(express.static("public")); | ||
app.use(bodyParser.urlencoded({extended: true})); | ||
|
||
app.get("/", function(req, res){ | ||
res.sendFile(__dirname + "/signup.html"); | ||
}); | ||
|
||
app.post("/", function(req, res){ | ||
|
||
const firstName = req.body.fName; | ||
const lastName = req.body.lName; | ||
const email = req.body.email; | ||
|
||
const data = { | ||
members: [ | ||
{ | ||
email_address: email, | ||
status: "subscribed", | ||
merge_fields: { | ||
FNAME: firstName, | ||
LNAME: lastName | ||
} | ||
} | ||
] | ||
}; | ||
|
||
const jsonData = JSON.stringify(data); | ||
|
||
const url = "https://us13.api.mailchimp.com/3.0/lists/451e475558"; | ||
|
||
const options = { | ||
method: "POST", | ||
auth: "aryan1:4e66c852a87967a1c24dd463ac9e3952-us13" | ||
}; | ||
|
||
const request = https.request(url, options, function(response){ | ||
if(response.statusCode == 200){ | ||
res.sendFile(__dirname + "/success.html"); | ||
} | ||
else res.sendFile(__dirname + "/failure.html"); | ||
response.on("data", function(data){ | ||
console.log(JSON.parse(data)); | ||
}); | ||
}); | ||
|
||
request.write(jsonData); | ||
request.end(); | ||
}); | ||
|
||
app.post("/failure", function(req, res){ | ||
res.redirect("/"); | ||
}); | ||
|
||
app.listen(3000, function(req, res){ | ||
console.log("Server is running on port 3000"); | ||
}); | ||
|
||
|
||
//API key | ||
// 4e66c852a87967a1c24dd463ac9e3952-us13 | ||
//unique id | ||
//451e475558 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
<!DOCTYPE html> | ||
<html lang="en"> | ||
<head> | ||
<meta charset="UTF-8"> | ||
<meta http-equiv="X-UA-Compatible" content="IE=edge"> | ||
<meta name="viewport" content="width=device-width, initial-scale=1.0"> | ||
<title>Failure</title> | ||
|
||
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap@4.5.3/dist/css/bootstrap.min.css" integrity="sha384-TX8t27EcRE3e/ihU7zmQxVncDAy5uIKz4rEkgIXeMed4M0jlfIDPvg6uqKI2xXr2" crossorigin="anonymous"> | ||
</head> | ||
<body> | ||
<div class="jumbotron jumbotron-fluid"> | ||
<div class="container"> | ||
<h1 class="display-4">Uh oh...</h1> | ||
<p class="lead">There was an error with signing up, please try again later or contact the developer.</p> | ||
<form action="/failure" method="post"> | ||
<button type="submit" name="button" class="btn btn-light btn-lg">Try Again!</button> | ||
</form> | ||
</div> | ||
</div> | ||
</body> | ||
</html> |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Check failure
Code scanning / CodeQL
Missing rate limiting