-
Notifications
You must be signed in to change notification settings - Fork 1
/
app.py
29 lines (26 loc) · 812 Bytes
/
app.py
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
from flask import Flask, request
import os, requests
from flask_cors import CORS
app = Flask(__name__)
CORS(app)
@app.route("/", methods=['GET','POST'])
def add_subscriber():
if request.method == 'POST':
url = "https://api.sendgrid.com/v3/contactdb/recipients"
header = {'Authorization': "Bearer "+ os.environ['SENDGRID_API_KEY']}
data = [{"email": request.form.get("email")}]
response = requests.post(url, headers=header, json=data)
return response.text
else:
return '''
<div style=\"position:relative; height:90%; width:100%; text-align:center;\">
<div style=\"position:absolute; top:25%; left:0; right:0;\">
Nothing to see here.
<br>
<br>
<img src=\"https://media1.giphy.com/media/10RgsuetO4uDkY/giphy.gif\">
</div>
</div>
'''
if __name__ == "__main__":
app.run()