INQ-24 js done, questions are from db now
This commit is contained in:
parent
978107b551
commit
870c4ff09d
11
App.py
11
App.py
@ -25,7 +25,12 @@ def home():
|
||||
|
||||
@app.route('/student',methods=['GET', 'POST'])
|
||||
def student():
|
||||
return render_template('student.html')
|
||||
db = sqlite3.connect(DATABASE)
|
||||
#db.row_factory = sql.Row
|
||||
db_conn = db.cursor()
|
||||
db_conn.execute("select * from question;")
|
||||
questions = db_conn.fetchall()
|
||||
return render_template('student.html', questions=questions)
|
||||
|
||||
@app.route('/ask', methods=['POST'])
|
||||
def do_add():
|
||||
@ -62,8 +67,8 @@ def upvote():
|
||||
db = sqlite3.connect(DATABASE)
|
||||
#db.row_factory = sql.Row
|
||||
db_conn = db.cursor()
|
||||
db_conn.execute("select * from user;")
|
||||
print(db_conn.fetchone())
|
||||
db_conn.execute("select * from question;")
|
||||
print(db_conn.fetchall())
|
||||
return '200'
|
||||
|
||||
|
||||
|
@ -19,9 +19,9 @@
|
||||
<div class="card-content">
|
||||
<span class="card-title card-title__body">Pytania studentów</span>
|
||||
<ul id="questions-list">
|
||||
<li>Pytanie odnośnie zadania domowego 12.11.2018<span class="counter"><i class="btn-thumb-up material-icons">thumb_up</i><span>12</span></span></li>
|
||||
<li>Zagadnienia dotyczące egzaminu<span class="counter"><i class="btn-thumb-up material-icons">thumb_up</i><span>45</span></span></li>
|
||||
<li>Czy 12 listopada odbędą się zajęcia?<span class="counter"><i class="btn-thumb-up material-icons">thumb_up</i><span>157</span></span></li>
|
||||
{% for question in questions %}
|
||||
<li>{{ question[3] }}<span class="counter"><i class="btn-thumb-up material-icons" id="{{ question[0] }}">thumb_up</i><span>{{ question[4] }}</span></span></li>
|
||||
{% endfor %}
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
@ -94,8 +94,10 @@
|
||||
|
||||
});
|
||||
$('.btn-thumb-up').on('click', () => {
|
||||
//alert(event.target.id)
|
||||
var link = '/upvote/' + event.target.id;
|
||||
$.ajax({
|
||||
url: '/upvote',
|
||||
url: link,
|
||||
type: 'POST',
|
||||
succes: function(response) {
|
||||
alert(response)
|
||||
|
Loading…
Reference in New Issue
Block a user