SHARE
TWEET

Untitled

a guest Feb 21st, 2019 77 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. from flask import Flask, request, redirect
  2. from twilio.twiml.messaging_response import MessagingResponse
  3. from pymongo import MongoClient
  4.  
  5.  
  6. client = MongoClient('localhost:5000')
  7.  
  8. members = client['member-db']
  9.  
  10. app=Flask(__name__)
  11.  
  12. @app.route("/sms", methods=['GET','POST'])
  13. def sms_reply():
  14.     resp = MessagingResponse()
  15.     if request.method == 'POST'
  16.         user = members['NetID']
  17.         body = request.form['Body']
  18.         netId = body.split[0]
  19.         passcode = body.split[1]
  20.         loginUser = user.find_one({'NetID': netId})
  21.         if loginUser is None:
  22.             usr ={
  23.                 "NetID": netId
  24.                 "Meetings": 1
  25.                 "Dates":
  26.                  }
  27.             user.insert_one(usr)
  28.         else
  29.             newMeet = db.members.find({"NetID": netId}, {Meetings:1, _id:0, Dates:0+1
  30.             db.members.update({"NetID": netId},{"Meetings": newMeet}, {upsert:true})
  31.         resp = MessagingResponse()
  32.         resp.message("Your response has been recorded, thank you!")
  33.     return str(resp)
  34.  
  35. if __name__=="__main__":
  36.     app.run(debug=True)
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top