Webhook_Router / app.py
Aum-Kansara's picture
Update app.py
de064fc
raw
history blame contribute delete
845 Bytes
from dotenv import load_dotenv
import os
from flask import Flask,jsonify,request
import requests
load_dotenv()
webhook_link=os.getenv("WEBHOOK_URL")
app=Flask(__name__)
@app.route('/')
def index():
return "Hello World"
@app.route('/getResponse')
def getResponse():
email=request.args.get('email','')
if email.strip()=='':
return "Provide Valid Question"
res=requests.get(webhook_link,params={"email":email})
if res.text.lower()=='accepted':
return "Server Error"
if int(res.text):
return jsonify({"question" : email,
"new_user":0,
"state_id" : res.headers['stateid'],
"name":res.headers['name']
})
return jsonify({"question" : email,
"new_user":1
})
if __name__=="__main__":
app.run(debug=True)