|
|
@ -45,6 +45,7 @@ def allowed_file(filename):
|
|
|
|
def home():
|
|
|
|
def home():
|
|
|
|
chat_form = ChatForm()
|
|
|
|
chat_form = ChatForm()
|
|
|
|
chat_messages = db.session.query(Chat).all()
|
|
|
|
chat_messages = db.session.query(Chat).all()
|
|
|
|
|
|
|
|
username = 'librarian'
|
|
|
|
|
|
|
|
|
|
|
|
# if request.method == 'POST':
|
|
|
|
# if request.method == 'POST':
|
|
|
|
# if chat_form.validate_on_submit():
|
|
|
|
# if chat_form.validate_on_submit():
|
|
|
@ -53,7 +54,7 @@ def home():
|
|
|
|
# db.session.add(msg)
|
|
|
|
# db.session.add(msg)
|
|
|
|
# db.session.commit()
|
|
|
|
# db.session.commit()
|
|
|
|
|
|
|
|
|
|
|
|
return render_template('home.html',domain=DOMAIN,chat=chat_messages, channel = 1, username="librarian")
|
|
|
|
return render_template('home.html',domain=DOMAIN,chat=chat_messages, channel = 1, username=username)
|
|
|
|
|
|
|
|
|
|
|
|
@app.route('/hello/<name>')
|
|
|
|
@app.route('/hello/<name>')
|
|
|
|
def hello(name):
|
|
|
|
def hello(name):
|
|
|
@ -368,6 +369,23 @@ def show_books():
|
|
|
|
return render_template ('show_books.html', books=books, form=search)
|
|
|
|
return render_template ('show_books.html', books=books, form=search)
|
|
|
|
|
|
|
|
|
|
|
|
if request.method == 'POST':
|
|
|
|
if request.method == 'POST':
|
|
|
|
|
|
|
|
newmsg = 'searched for: ' + search.search.data
|
|
|
|
|
|
|
|
# message = search.search.data
|
|
|
|
|
|
|
|
# newmessage = Chat(message)
|
|
|
|
|
|
|
|
# db.session.add(newmessage)
|
|
|
|
|
|
|
|
# db.session.commit()
|
|
|
|
|
|
|
|
# Send search to socket chat
|
|
|
|
|
|
|
|
socketio.emit('channel-' + str(1), {
|
|
|
|
|
|
|
|
'username': 'Search form',
|
|
|
|
|
|
|
|
'text': search.search.data,
|
|
|
|
|
|
|
|
'time': str(datetime.datetime.utcnow().strftime("%d.%m.%Y %H:%M"))}, broadcast=True)
|
|
|
|
|
|
|
|
# Save message
|
|
|
|
|
|
|
|
my_new_chat = Chat(message=newmsg)
|
|
|
|
|
|
|
|
db.session.add(my_new_chat)
|
|
|
|
|
|
|
|
try:
|
|
|
|
|
|
|
|
db.session.commit()
|
|
|
|
|
|
|
|
except:
|
|
|
|
|
|
|
|
db.session.rollback()
|
|
|
|
return redirect((url_for('search_results', searchtype=search.select.data, query=search.search.data, viewby=viewby)))
|
|
|
|
return redirect((url_for('search_results', searchtype=search.select.data, query=search.search.data, viewby=viewby)))
|
|
|
|
|
|
|
|
|
|
|
|
return render_template('show_books.html', books=books, form=search)
|
|
|
|
return render_template('show_books.html', books=books, form=search)
|
|
|
@ -415,6 +433,19 @@ def search_results(searchtype, query, viewby):
|
|
|
|
return render_template('results_grid.html', books=results, form=search, query=query, books_all=random_order, searchtype=search.select.data, count = count, whole = whole, percentage = percentage)
|
|
|
|
return render_template('results_grid.html', books=results, form=search, query=query, books_all=random_order, searchtype=search.select.data, count = count, whole = whole, percentage = percentage)
|
|
|
|
|
|
|
|
|
|
|
|
if request.method == 'POST':
|
|
|
|
if request.method == 'POST':
|
|
|
|
|
|
|
|
newmsg = 'searched for: ' + search.search.data
|
|
|
|
|
|
|
|
socketio.emit('channel-' + str(1), {
|
|
|
|
|
|
|
|
'username': 'Search form',
|
|
|
|
|
|
|
|
'text': search.search.data,
|
|
|
|
|
|
|
|
'time': str(datetime.datetime.utcnow().strftime("%d.%m.%Y %H:%M"))}, broadcast=True)
|
|
|
|
|
|
|
|
# Save message
|
|
|
|
|
|
|
|
my_new_chat = Chat(message=newmsg)
|
|
|
|
|
|
|
|
db.session.add(my_new_chat)
|
|
|
|
|
|
|
|
try:
|
|
|
|
|
|
|
|
db.session.commit()
|
|
|
|
|
|
|
|
except:
|
|
|
|
|
|
|
|
db.session.rollback()
|
|
|
|
|
|
|
|
|
|
|
|
query = search.search.data
|
|
|
|
query = search.search.data
|
|
|
|
results = []
|
|
|
|
results = []
|
|
|
|
if viewby == '1':
|
|
|
|
if viewby == '1':
|
|
|
@ -562,7 +593,6 @@ def new_message(message):
|
|
|
|
db.session.rollback()
|
|
|
|
db.session.rollback()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if __name__ == '__main__':
|
|
|
|
if __name__ == '__main__':
|
|
|
|
socketio.run(app)
|
|
|
|
socketio.run(app)
|
|
|
|
#app.run(debug=True,host="0.0.0.0",port="8080")
|
|
|
|
#app.run(debug=True,host="0.0.0.0",port="8080")
|
|
|
|