20. Middlewares of Liao Xuefeng's Python combat Day5 [translation] module inspect — Inspect live objects

Paste the main function code first:

async def init(loop):
    await orm.create_pool(loop=loop, host='127.0.0.1', port=3306, user='root', password='root', db='awesome')    #1
    app = web.Application(loop=loop, middlewares=[    #2
        logger_factory, response_factory
    ])
    init_jinja2(app, filters=dict(datetime=datetime_filter))    #3
    add_routes(app, 'handlers')    #4
    add_static(app)    #5
    srv = await loop.create_server(app.make_handler(), '127.0.0.1', 9000)    #6
    logging.info('server started at http://127.0.0.1:9000...')
    return srv

loop = asyncio.get_event_loop()
loop.run_until_complete(init(loop))
loop.run_forever()

#1: Create a database connection pool;

#2: Create a Web Application object, where middlewares will be described later;

#3: Template framework for later use;

#4: Add the URL processing function in the handlers module to the router of the Web Application;

#5: Add static files such as css;

#6: Create a server to accept processing requests;

 

This section is a difficult point. After researching various data for more than a week, the experience is as follows:

1. Available information

1. Function parameters

Various parameters in the coroweb module to judge the URL processing function in the handlers module (positional parameters, default parameters, variable parameters, keyword parameters, named keyword parameters)

Parameters of the function of Liao Xuefeng's Python tutorial

2, inspect module related

(1) [reprint] inspect module in python

(2) [Translation] Module inspect — Inspect live objects

3、

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325120534&siteId=291194637