Create a gist now

Instantly share code, notes, and snippets.

What would you like to do?
Это файлики для моего второго скринкаста. Они еще проще, чем первые. Подробности можно
<title>Girls gone wild!</title>
<link rel="stylesheet" type="text/css" href="/static/style.css">
<script type="text/javascript" src=""></script>
<script type="text/javascript" src="http://localhost:8080/application.js"></script>
<script type="text/javascript">
$(document).ready(function () {
var jug = new Juggernaut;
jug.subscribe('babes', function (data) {
$('li').click(function () {
var mash = $('li');
for (var i = mash.length - 1; i >= 0; i--) {
if (this == mash[i]) {
url: '/vote/' + i,
method: 'POST',
success: function (data) {
function changeValue(data) {
$('.votescounter')[data.babe].innerHTML = data.result;
<li><img src="/static/babes/1.jpeg"/><span class="votescounter"></span></li>
<li><img src="/static/babes/2.jpeg"/><span class="votescounter"></span></li>
<li><img src="/static/babes/3.jpeg"/><span class="votescounter"></span></li>
<li><img src="/static/babes/4.jpeg"/><span class="votescounter"></span></li>
<li><img src="/static/babes/5.jpeg"/><span class="votescounter"></span></li>
from flask import Flask, redirect, jsonify
from juggernaut import Juggernaut
from redis import Redis
app = Flask(__name__)
app.debug = True
db = Redis()
jug = Juggernaut()
def hello():
return redirect('/static/index.html')
@app.route('/vote/<int:voteid>', methods=['POST'])
def vote(voteid):
if voteid < 0 or voteid > 4:
return jsonify({'error': 'strange vote?!'})
res = db.incr('babes:vote:' + str(voteid))
result = {'result': res, 'babe': voteid}
jug.publish('babes', result)
return jsonify(result)
if __name__ == '__main__':
body {
background-color: #f0f0f0;
ul {
list-style-type: none;
.votescounter {
font-size: 200px;
margin-left: 100px;
color: #505050;

Ишь какая кадавра на jQuery: я аж пароль от гитхаба вспомнил! Кажется, мои маленькие исправления (в форке) функциональность не рушат. Спасибо за скринкаст!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment