Created
January 19, 2015 23:44
-
-
Save kunal732/4ecd43da173fd8aca1e9 to your computer and use it in GitHub Desktop.
Crunchbase and SendGrid mashup
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
from flask import Flask, request | |
import sendgrid | |
import requests | |
app = Flask(__name__) | |
@app.route ('/incoming', methods =['POST']) | |
def nextweb(): | |
subject = request.form['subject'] | |
body = request.form['text'] | |
mailfrom = request.form['from'] | |
print subject | |
url = 'https://api.crunchbase.com/v/2/organization/'+subject+'?user_key=your_crunchbase_key' | |
r = requests.get(url) | |
#print r | |
print url | |
desc = r.json() | |
comp_info = desc["data"]["properties"]["description"] | |
body = " ### " +subject+ " ### " | |
body = body + comp_info | |
sg = sendgrid.SendGridClient('your_user_name', 'your_pass') | |
message = sendgrid.Mail() | |
message.add_to(mailfrom) | |
message.set_subject('Re: '+subject) | |
message.set_html(body) | |
message.set_text(body) | |
message.set_from('[email protected]') | |
status, msg = sg.send(message) | |
return "OK" | |
if __name__=='__main__': | |
app.run(debug=True) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment