Note that there are some explanatory texts on larger screens.

plurals
  1. POPythonic realtime to update one element in webpage?
    text
    copied!<p>For the past several days, I have looked into starting to turn my website towards realtime. I looked at Gevent (can't use b/c I'm using Python 3.3), Tornado, and Webalchemy.</p> <p>Webalchemy and Tornado are both options. At this time, I have not successfully meshed their code with mine..that is, I have not been able to get a realtime result. I have set a modest goal for myself: getting the upvote/downvote ticker to display in realtime.</p> <p>This is my upvote function:</p> <pre><code>@mod.route('/updebate/&lt;int:entries_did&gt;') def up_vote(entries_did): connection = g.db.session.connection() g.db.engine.execute( 'update users_user set rating = rating + 1 where id in (select id from users_debates where users_debates.did ="{0}")'.format(entries_did)) g.db.engine.execute( 'update users_debates set rating = rating + 1 where did = "{0}"'.format(entries_did)) # g.db.commit() return redirect(request.referrer) </code></pre> <p>As you can see, right now I'm simply "request.referrer"-ing..definitely not what I want to do.</p> <p>Here is the code from my HTML page:</p> <pre><code>{% for entry in entries %} &lt;li&gt;&lt;h2&gt; &lt;a href="/updebate/{{ entry.did }}" style="text-decoration:none; color:orange;"&gt;&amp;#11014;&lt;/a&gt;{{ entry.rating }}&lt;a href="/downdebate/{{ entry.did }}" style="text-decoration:none; color:orange;"&gt;&amp;#11015;&lt;/a&gt;&lt;a href="/debate/{{ entry.did }}"&gt;{{ entry.title }}&lt;/a&gt;&lt;/h2&gt;{{ entry.text|safe }} CREATED BY: {{ entry.name }} {% else %} &lt;li&gt;&lt;em&gt;Unbelievable. No entries here so far&lt;/em&gt; {% endfor %} </code></pre> <p>Thoughts?</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload