-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest.txt
127 lines (110 loc) · 3.23 KB
/
test.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<meta
name="viewport"
content="width=device-width, initial-scale=1, shrink-to-fit=no"
/>
<meta name="description" content="" />
<meta name="author" content="" />
<title>Newsletter Signup</title>
<link
rel="canonical"
href="https://getbootstrap.com/docs/4.0/examples/sign-in/"
/>
<!-- Bootstrap core CSS -->
<link
href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css"
rel="stylesheet"
integrity="sha384-0evHe/X+R7YkIZDRvuzKMRqM+OrBnVFBL6DOitfPri4tjfHxaWutUpFmBp4vmVor"
crossorigin="anonymous"
/>
<script
src="https://cdn.jsdelivr.net/npm/[email protected]/dist/js/bootstrap.bundle.min.js"
integrity="sha384-pprn3073KE6tl6bjs2QrFaJGz5/SUsLqktiwsUTF55Jfv3qYSDhgCecCxMW52nD2"
crossorigin="anonymous"
></script>
<!-- Custom styles for this template -->
<link href="/styles/style.css" rel="stylesheet" />
</head>
<body class="text-center">
<form class="form-signin" method="post" action="/">
<img class="mb-4" src="/images/email.png" alt="" width="72" height="72" />
<h1 class="h3 mb-3 font-weight-normal">Sign Up to My Newsletter</h1>
<input
type="text"
name="firstName"
class="form-control top"
placeholder="First Name"
required
autofocus
/>
<input
type="text"
name="lastName"
class="form-control middle"
placeholder="Last Name"
required
/>
<input
type="email"
name="email"
class="form-control bottom"
placeholder="Email address"
required
autofocus
/>
<button class="btn btn-lg btn-primary btn-block" type="submit">
Sign Me Up
</button>
<p class="mt-5 mb-3 text-muted">© PradipSubedi</p>
</form>
</body>
</html>
const express = require("express");
const bodyParser = require("body-parser");
const https = require("https");
const request = require("request");
const path = require("path");
const app = express();
app.use(bodyParser.urlencoded({ extended: true }));
app.use(express.static(path.join(__dirname, "public")));
app.get("/", function (req, res) {
res.sendFile(__dirname + "/signup.html");
});
app.post("/", function (req, res) {
const firstName = req.body.firstName;
const email = req.body.email;
const lastName = req.body.lastName;
const data = {
members: [
{
email_address: email,
status: "subscribed",
merge_fields: {
FNAME: firstName,
LNAME: lastName,
},
},
],
};
const jsonData = JSON.stringify(data);
const url = "https://us17.api.mailchimp.com/3.0/lists/32411140c7";
const options = {
method: "POST",
auth: "pradip1:8bde9a2c0a77b9d6147ad7cf3132e01a-us17",
};
const request = https.request(url, options, function (response) {
response.on("data", function (data) {
console.log(JSON.parse(data));
});
});
request.write(jsonData);
res.end();
});
app.listen(3000, function () {
console.log("Server started on port 3000");
});
//List ID key = 32411140c7
//API Key = 8bde9a2c0a77b9d6147ad7cf3132e01a-us17