View tornado-index.py
import asyncio | |
from handler import server | |
from libs.redis import MyRedis | |
async def init_redis(): | |
await MyRedis.redis() | |
if __name__ == '__main__': |
View redis-singleton.py
import aioredis | |
class MyRedis(object): | |
_redis = None | |
@classmethod | |
async def redis(cls): | |
if not cls._redis: | |
cls._redis = await aioredis.create_redis('redis://localhost') |
View flask-dynamic-router.py
for i in ['aa', 'bb']: | |
option = {} | |
option['endpoint'] = i | |
rule = app.url_rule_class('/' + i, methods=('GET',), **option) | |
app.url_map.add(rule) | |
app.view_functions[i] = lambda: jsonify({'success': i}) |
View parse_img_demo.py
def save_img(path, url): | |
pass | |
def update_path(): | |
pass | |
def get_img_url(url): | |
pass | |
def get_page_num(): |
View ModuleFinder.py
class ModuleFinder(object): | |
def __init__(self): | |
self.find_next_line = False | |
self.father_module = None | |
self.modules = [] | |
def find_modules_next_line(self, code, module=None): | |
"""code: line to find modules""" | |
if '\\' not in code[-1]: |
View tornado_motorengine_testing.py
from tornado.web import Application | |
from tornado.testing import AsyncHTTPTestCase | |
from apps.account.handlers import CheckEnv | |
import unittest | |
import motorengine | |
class MyTestCase(AsyncHTTPTestCase): | |
def setUp(self, auto_connect=True): | |
super(MyTestCase, self).setUp() |