#本文是在Windows环境下, a UNIX system should have 2 more things to set up.
(i) designing Web applications with MVC
Follow model-View-controller (Model-view-controlle)
Model: Code that stores web app data
View: Formatting and displaying code for the Web App user interface
Controllers: Code that binds web apps together and provides business logic
(ii) Recommended folder structure
WebAPP: Custom
Cgi-bin: Store Code
Data: Storage
Images: Storing pictures
Templates: Storing templates
(iii) CGI let the Web server run the program
Create a Python file (build a Web server in Python with the following code)
from Http.server import Httpserver,cgihttprequesthandler
Port = 8099
httpd = Httpserver (("', Port), Cgihttprequesthandler)
Print (' port number is '+ str (httpd.server_port))
Httpd.serve_forever ()
(iv) Run
start.py is the file I used to store the code above.
Access:
(v) Source Code
Interested in can be downloaded to the network disk reference
Https://pan.baidu.com/s/1diVNuY Password: xsaz
Then, (1) Use Pycharm (with your own IDE) to create a project.
(2) Copy the following files to the project.
(3) Right click on Cgi-bin, set the following. (Do not set the direct import of their own module will be error) and then put the inside generate_list.py, Yate.py these 2 files in the code of the absolute path to your own path (originally want to use a relative path, but do not know why the use of relative path when the IDE can be run, the Web server running error)
(4) Then you can run access to the http://localhost:8099 (if you change the port number with the modified)
Python notes (eight): Web development