Basic operation:
Routing System:
url -> type (according to the method to perform the method)
Controller
class Foo(11111):
def get(self):
self.render
self.write
self.redirect
self.get_argument()
self.get_arguments()
self.get_cookie()
self.set_cookie('xxxxx','000000')
Set up an encrypted cookie (you need to configure the settings inside cookie_secret)
self.get_secure_cookie('xxxxxx')
self.set_secure_cookie('xxxxxx','00000')
def post(self):
self.request.files['aaa']
self._headers # request header
# Find request to Handler objects, self.request objects
Template engine (closer python)
{{[0]}}
{% for i in range(10) %}
{% end %}
UImethod, UImodule, custom method in the template
UImethod: Content
UImodule: css, js, content
Custom session:
self.session['xx'] = "adadawddw" # __setitem__
self.session['xx'] # __getitem__
del self.session['xx'] # __delitem__
Find the order 1.super
Class name. Method name (self)
Object method is always invoked 2.self
container = {}
def create_random_str(self):
v = str(time.time())
m = hashlib,md5()
m.update(bytes(v,encoding='utf8'))
return m.hexdigest()
def __setitem__(self,key,value):
random_str = self.create_random_str()
self.handler.set_cookie('session_id',random_str)
if random_str in container:
container[random_str][key] = value
else:
container[random_str]={}
container[random_str][key] = value