This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import asyncio | |
from handler import server | |
from libs.redis import MyRedis | |
async def init_redis(): | |
await MyRedis.redis() | |
if __name__ == '__main__': |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import aioredis | |
class MyRedis(object): | |
_redis = None | |
@classmethod | |
async def redis(cls): | |
if not cls._redis: | |
cls._redis = await aioredis.create_redis('redis://localhost') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def save_img(path, url): | |
pass | |
def update_path(): | |
pass | |
def get_img_url(url): | |
pass | |
def get_page_num(): |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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]: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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() |