Skip to content

Commit bf84d50

Browse files
committed
First Commit
0 parents  commit bf84d50

File tree

1,011 files changed

+161985
-0
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

1,011 files changed

+161985
-0
lines changed

Procfile

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
web: node app.js

app.js

+73
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
// jshint esversion:6
2+
3+
const express = require("express");
4+
const bodyParser = require("body-parser");
5+
const request = require("request");
6+
const https = require("https");
7+
8+
const app = express();
9+
10+
app.use(express.static("public"));
11+
app.use(bodyParser.urlencoded({extended: true}));
12+
13+
app.get("/", function(req,res){
14+
res.sendFile(__dirname + "/signup.html");
15+
} )
16+
17+
app.post("/", function(req,res){
18+
19+
const firstName = req.body.fname;
20+
const lastName = req.body.lname;
21+
const email = req.body.email;
22+
23+
const data={
24+
members:[
25+
{
26+
email_address: email,
27+
status:"subscribed",
28+
merge_fields:{
29+
FNAME:firstName,
30+
LNAME:lastName,
31+
}
32+
}
33+
]
34+
};
35+
36+
const jsonData = JSON.stringify(data);
37+
38+
const url = "https:/us21.api.mailchimp.com/3.0/lists/4916d25844" ;
39+
40+
const options = {
41+
method:"POST",
42+
auth: "Harshdev:1595497f139afda2d0daa22c83effa6b-us21"
43+
}
44+
45+
46+
const request = https.request(url, options, function(response){
47+
if (response.statusCode === 200){
48+
res.sendFile(__dirname + "/success.html")
49+
} else{
50+
res.sendFile(__dirname + "/failure.html")
51+
}
52+
response.on("data",function(data){
53+
console.log(JSON.parse(data));
54+
});
55+
});
56+
request.write(jsonData);
57+
request.end();
58+
});
59+
60+
app.post("/failure", function(req,res){
61+
res.redirect("/")
62+
})
63+
64+
65+
app.listen(process.env.PORT || 3000, function(){
66+
console.log("Server is running on 3000");
67+
});
68+
69+
// api key
70+
// 1595497f139afda2d0daa22c83effa6b-us21
71+
72+
// audience id
73+
// 4916d25844

failure.html

+22
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
<!DOCTYPE html>
2+
<html lang="en">
3+
<head>
4+
<meta charset="UTF-8">
5+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
6+
<title>Failure</title>
7+
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css" integrity="sha384-MCw98/SFnGE8fJT3GXwEOngsV7Zt27NXFoaoApmYm81iuXoPkFOJwJ8ERdknLPMO" crossorigin="anonymous">
8+
9+
</head>
10+
<body>
11+
<div class="jumbotron jumbotron-fluid">
12+
<div class="container">
13+
<h1 class="display-4">Uh oh!</h1>
14+
<p class="lead">There is a problem signing you up. Please try again or contact the developer</p>
15+
16+
<form action="/failure" method="post">
17+
<button class="btn btn-lg btn-warning" type="submit" name="button">Try again</button>
18+
</form>
19+
</div>
20+
</div>
21+
</body>
22+
</html>

node_modules/.bin/mime

+12
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

node_modules/.bin/mime.cmd

+17
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

node_modules/.bin/mime.ps1

+28
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

node_modules/.bin/sshpk-conv

+12
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

node_modules/.bin/sshpk-conv.cmd

+17
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

node_modules/.bin/sshpk-conv.ps1

+28
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

node_modules/.bin/sshpk-sign

+12
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

node_modules/.bin/sshpk-sign.cmd

+17
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

node_modules/.bin/sshpk-sign.ps1

+28
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

node_modules/.bin/sshpk-verify

+12
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

node_modules/.bin/sshpk-verify.cmd

+17
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

node_modules/.bin/sshpk-verify.ps1

+28
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

node_modules/.bin/uuid

+12
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

node_modules/.bin/uuid.cmd

+17
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)