daily pastebin goal
40%
SHARE
TWEET

Untitled

a guest Dec 16th, 2018 88 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. from flask import Flask, request, jsonify
  2.  
  3. app = Flask(__name__)
  4.  
  5.  
  6. @app.route('/subscribe', methods=['GET'])
  7. def add_subscribers():
  8.     email_address = request.args.get('email')
  9.     #   add the subscribers to the email list
  10.     try:
  11.         write(email_address)
  12.         return "Okay", 200
  13.     except Exception as e:
  14.         return e, 500
  15.  
  16.  
  17. @app.route('/list', methods=['GET'])
  18. def show_subscribers():
  19.     try:
  20.         mails = read()
  21.         email_json = {"emails": mails}
  22.         return jsonify(email_json)
  23.     except Exception as e:
  24.         return e, 500
  25.  
  26.  
  27. if __name__ == "__main__":
  28.     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