Esempio n. 1
0
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"
Esempio n. 2
0
def searchSubjectTopic():
    search.populateSubjectTopic()
    searchTerm = request.args.get('q')
    return dumps(search.searchTopic(searchTerm))
Esempio n. 3
0
def createTopic():
    title = request.get_json()['topic']
    subject = request.get_json()['subject']
    result = topics.create_topic(title, subject)
    search.populateSubjectTopic()
    return (' ', 201)
Esempio n. 4
0
def delete_topic():
    req = request.get_json()
    topic = req['topic'].lower()
    db.db.topics.delete_one({"title": topic})
    search.populateSubjectTopic()
    return "DONE"
Esempio n. 5
0
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)