Spaces:
Sleeping
Sleeping
Commit
·
2781348
1
Parent(s):
70352cc
Create app.py
Browse files
app.py
ADDED
|
@@ -0,0 +1,33 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
from dotenv import load_dotenv
|
| 2 |
+
import os
|
| 3 |
+
from flask import Flask,jsonify,request
|
| 4 |
+
import requests
|
| 5 |
+
load_dotenv()
|
| 6 |
+
webhook_link=os.getenv("WEBHOOK_URL")
|
| 7 |
+
|
| 8 |
+
app=Flask(__name__)
|
| 9 |
+
|
| 10 |
+
|
| 11 |
+
@app.route('/')
|
| 12 |
+
def index():
|
| 13 |
+
return "Hello World"
|
| 14 |
+
|
| 15 |
+
@app.route('/getResponse')
|
| 16 |
+
def getResponse():
|
| 17 |
+
email=request.args.get('email','')
|
| 18 |
+
if email.strip()=='':
|
| 19 |
+
return "Provide Valid Question"
|
| 20 |
+
res=requests.get(webhook_link,params={"email":email})
|
| 21 |
+
if res.text.lower()=='accepted':
|
| 22 |
+
return "Server Error"
|
| 23 |
+
if int(res.text):
|
| 24 |
+
return jsonify({"question" : email,
|
| 25 |
+
"new_user":0,
|
| 26 |
+
"state_id" : res.headers['stateid']
|
| 27 |
+
})
|
| 28 |
+
return jsonify({"question" : email,
|
| 29 |
+
"new_user":1
|
| 30 |
+
})
|
| 31 |
+
|
| 32 |
+
if __name__=="__main__":
|
| 33 |
+
app.run(debug=True)
|