Files
codeql/python/ql/test/experimental/query-tests/Security/CWE-079/sendgrid_mail.py
thank_you 3a4e3d5146 Remove comments from Python example tests
Besides removing comments, I also reduced the complexity of some of the Python code examples.
2021-10-30 14:00:51 -04:00

31 lines
925 B
Python

from flask import request, Flask
from sendgrid import SendGridAPIClient
from sendgrid.helpers.mail import Mail, Email, To, Content, MimeType
app = Flask(__name__)
@app.route("/send")
def send():
message = Mail(
from_email='from_email@example.com',
to_emails='to@example.com',
subject='Sending with Twilio SendGrid is Fun',
html_content=request.args["html_content"])
sg = SendGridAPIClient('SENDGRID_API_KEY')
sg.send(message)
@app.route("/send_post")
def send_post():
from_email = Email("test@example.com")
to_email = To("test@example.com")
subject = "Sending with SendGrid is Fun"
content = Content("text/html", request.args["html_content"])
content = Content(MimeType.html, request.args["html_content"])
mail = Mail(from_email, to_email, subject, content)
sg = SendGridAPIClient(api_key='SENDGRID_API_KEY')
response = sg.client.mail.send.post(request_body=mail.get())