Giter Site home page Giter Site logo

tornado_restful's Introduction

一个基于tornado的Restful微服务基础框架

环境要求:python 3.6+, tornado 6.x

  1. 集成异步mysql连接池aiomysql、异步redis连接池aioredis、异步文件流库aiofiles,采用uvloop加速asyncio事件循环,充分发挥tornado异步特性

  2. 集成基于异步redis连接池的session

  3. 集成验证码:http://localhost:xxxx/imgcode?cur=xxxxxxxxxxxxxxxxxxxx&pre=xxxxxxxxxxxxxxxxxxxxx

  4. 采用orjson代替json优化dict的序列与反序列化

  5. 优化xsrf_cookies校验规则

  6. 可插拔式路由:

    • 继承handlers.ApiHandler,添加route类属性
    • handlers文件夹下的__init__.py文件中导入继承的类

    即可完成路由解析

    example:

    from handlers import ApiHandler
    
    class TestHandler(ApiHandler):
        route = r'/test/?([^/]*)/?'
    
        async def get(self, name):
            self.write(f'this is a test!{f" name: {name}" if name else ""}')

    __init__.py:

    from .test_handler import TestHandler

    浏览器访问http://localhost:xxxx/testhttp://localhost:xxxx/test/myname

  7. Restful接口

tornado_restful's People

Contributors

jenifly avatar

Stargazers

hzb avatar oxf4vul avatar

Watchers

James Cloos avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.