Build the development environment
First, confirm that the Python version of the system installation is 2.7.x:
$ python --versionPython 2.7.5
Then, install the third-party libraries you need to develop your web app:
Front-end template engine jinja2:
$ sudo apt-get install python-jinja*
有python-jinja2 和python3-jinja2,以及python-jinja2-doc
MySQL 5.x database, downloaded from the official website and installed, after installation, it is important to remember the root password. To avoid forgetting passwords, it is recommended to set the root password directly password ;
$ sudo apt-get install mysql-server-5.6
MySQL python driver Mysql-connector-python:
$ sudo apt-get install python-mysql.connector
Project structure
Select a working directory, and then we create the following directory structure:
awesome-python-webapp/ <-- 根目录|+- backup/ <-- 备份目录|+- conf/ <-- 配置文件|+- dist/ <-- 打包目录|+- www/ <-- Web目录,存放.py文件| || +- static/ <-- 存放静态文件| || +- templates/ <-- 存放模板文件|+- LICENSE <-- 代码LICENSE
Once you've created your project's directory structure, it's recommended that you set up a git repository and sync to GitHub to keep your code changes safe.
To learn about git and github usage, go to the Git tutorial.
Development tools
Sublime Text is recommended for your own use.
Python Web develop-1 set up environment