コード例 #1
0
ファイル: manager.py プロジェクト: cloudorz/codewow
#!/usr/bin/env python
# coding: utf-8

from codewow import create_app
from codewow.models import Gist, User, Stat

from flaskext.script import Server, Shell, Manager, Command, prompt_bool


manager = Manager(create_app('dev.cfg'))

manager.add_command("runserver", Server('0.0.0.0',port=8080))

@manager.command
def stat():
    ''' update the stat data command
    '''
    last = Stat.query.descending(Stat.mongo_id).first()
    if last:
        gists = Gist.query.filter(Gist.mongo_id.ge_(last.mongo_id))
        users = User.query.filter(User.mongo_id.ge_(last.mongo_id))
    else:
        gists = Gist.query
        users = User.query

    tag_list = []
    tag_set = set()
    for e in gists:
        tag_list.extend(e.tags)
        tag_set.update(e.tags)
コード例 #2
0
ファイル: gevent_server.py プロジェクト: linkexf/codewow
# coding: utf-8
from gevent.wsgi import WSGIServer
from codewow import create_app

app = create_app('production.cfg')

http_server = WSGIServer(('127.0.0.1', 8000), app)
http_server.serve_forever()
コード例 #3
0
#!/usr/bin/env python
# coding: utf-8

from codewow import create_app
from codewow.models import Gist, User, Stat

from flaskext.script import Server, Shell, Manager, Command, prompt_bool

manager = Manager(create_app('dev.cfg'))

manager.add_command("runserver", Server('0.0.0.0', port=8080))


@manager.command
def stat():
    ''' update the stat data command
    '''
    last = Stat.query.descending(Stat.mongo_id).first()
    if last:
        gists = Gist.query.filter(Gist.mongo_id.ge_(last.mongo_id))
        users = User.query.filter(User.mongo_id.ge_(last.mongo_id))
    else:
        gists = Gist.query
        users = User.query

    tag_list = []
    tag_set = set()
    for e in gists:
        tag_list.extend(e.tags)
        tag_set.update(e.tags)