Created
January 20, 2015 00:22
-
-
Save kunal732/7e66e6bfbee30be5d99b to your computer and use it in GitHub Desktop.
Gets crunchbase analysis of sending email domain and returns an email to the user
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'] | |
domain = mailfrom.split("@")[1].rstrip(".com>") | |
print domain | |
url = 'https://api.crunchbase.com/v/2/organization/'+domain+'?user_key=your_crunchbase_key' | |
r = requests.get(url) | |
#print r | |
#print url | |
desc = r.json() | |
comp_info = desc["data"]["properties"]["description"] | |
body = " ### " +domain+ " ### " | |
body = body + comp_info | |
sg = sendgrid.SendGridClient('SG_user', 'SG_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