Tornado website building starts from 0. All registered users are displayed.

Source: Internet
Author: User

The main code for displaying the registered user's front-end is as follows:

{% Block content %} <ul >{% for I in users %} <li> <a href = '/user/{I [1]}' class =' text-success h4 '>{{ I [1] }}< small> ({I [3]} star) </small> </a> </li> {% end %} <br/> </ul> {% end %}

The background code for displaying registered users is as follows:

Class memberHandler (tornado. web. requestHandler): def get (self): name = self. get_cookie ('hackername') users = show () users. sort (key = lambda x: xforwar3}, reversew.true=self.render('member.html ', cookieName = name, users = users)

The show function is:

Def show (): c.exe cute ('select * from user') return c. fetchall ()

The user table is defined as follows:

Create table user (id integer primary key, name text, pw text, level integer );

Displays the ranking of users by user level. The effect is as follows:



Reprinted Please note:

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.