Online question and answer system based on Python tornado

Source: Internet
Author: User
Tags virtual environment

Overview This project uses the latest tornado development. Realize online questions, answers, comments and other functions. Using the tornado generator, long polling and so on, support the asynchronous connection of MySQL. Detailed code Download: http://www.demodashi.com/demo/13926.html

Project Introduction: This project was originally designed to imitate StackOverflow's practiced hand project, and realized part of the StackOverflow function.

Project Description: It is recommended to deploy this project using Linux, which optimizes the performance of tornado. My environment is Windows plus Python3.6.5.

Directory structure:

Database:mysql/redis, such as asynchronous connectors, data manipulation methods.

Handlers:tornado Controller Files

Static: File Address

Templats:html page Address

Utils:python Utility Script

Conf: Configuration file

local_conf.bak.py: Sample Local configuration file

manage.py: Program Start entry

Require: Dependency packages, using PIP installation

router.py: Routing

0: Download the tarball to extract the project source files to the specified directory. My directory is c:\users\zhang\downloads\tequila-master\tequila-master>.

1: Create the VENV virtual environment in the project root directory, virtualenv venv--no-site-packages

2: Activating the virtual Environment venv\scripts\activate

3: Install Python package dependent pip Install-r require

4: Modify the local_conf.bak.py file name to local_conf.py, and edit the local_conf.py file as follows:

#-*-coding:utf-8-*-import osdomain = ' http://127.0.0.1:9000 ' Default_upload_path = Os.path.join (Os.path.dirname (__ file__), ' pics ') DATABASE = {'    default ': {        ' host ': ' localhost ',        ' Port ': 3306,        ' database ': ' Tequila_ Demo ',        ' user ': ' Root ',        ' password ': ' Your Database password ', '        charset ': ' UTF8 '    }}redis = {    ' default ': {        ' Host ': ' localhost ',        ' Port ': 6379,        ' password ': ', '        selected_db ': 0,    }}

5: Create Database Tequila_demo;

6: Perform a script migration to create initialization data. Python manage.py Migrate

7: See if the data table was created successfully and check if Redis is available

8: Run the project, Python manage.py run, if your system is windows, you will not be able to use the Tornado Fork process mode and you will encounter the following error:

Do not panic at this time, you only need to modify the manage.py file, the Server.start (num_process=4) modified to Server.start () can be

Last rerun project: Python manage.py Run

9: Browser Access http://127.0.0.1:9000

The above is part of the project page, if you have any questions about the project can contact me ~

Code Download: http://www.demodashi.com/demo/13926.html Note: This copyright belongs to the author, published by the demo master, refused to reprint, reprint needs the author authorization

Online question and answer system based on Python tornado

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.