def send_summary(): body = request.form.get('body') topic = request.form.get('topic') email = loads(session["user_info"]) msg = Message(subject="Your summary from " + topic, sender=app.config.get("MAIL_USERNAME"), recipients=[email]) msg.html = render_template("email.html", content=body) mail.send(msg) topic = req['topic'].lower() subject = req['subject'].lower() topics.create_topic(topic, subject) search.populateSubjectTopic() return "DONE"
def searchSubjectTopic(): search.populateSubjectTopic() searchTerm = request.args.get('q') return dumps(search.searchTopic(searchTerm))
def createTopic(): title = request.get_json()['topic'] subject = request.get_json()['subject'] result = topics.create_topic(title, subject) search.populateSubjectTopic() return (' ', 201)
def delete_topic(): req = request.get_json() topic = req['topic'].lower() db.db.topics.delete_one({"title": topic}) search.populateSubjectTopic() return "DONE"
def on_leave(data): leave_room() socketio.send({"msg": data["from_username"] + " has left the room"}, room=data["room"]) @app.after_request def middleware_for_response(response): # Allowing the credentials in the response. response.headers.add('Access-Control-Allow-Credentials', 'true') return response if __name__ == '__main__': search.initializeIndexSubject() search.populateSubjectTopic() socketio.run(app, debug=True) # Unused code ''' @app.route('/login', methods=["POST"]) @cross_origin(supports_credentials=True) def login(): req = request.get_json() print(req) username = req['username'].lower() password = req['password'] session["user_info"] = auth.login(username, password) return session["user_info"] @app.route('/register', methods=["POST"]) @cross_origin(supports_credentials=True)