I think the advantage of Python to develop web services is that the development efficiency will be very high. It is said that only one-fifth of the code of Java can be used to achieve the same function. Therefore, web services with low performance requirements can be developed in Python.
There are many frameworks for building web services in Python, and today I will experience one of the most common Djangos. I have installed the Python development environment before, and pip has also been installed. Students who do not have these two things can refer to the article I wrote about crawlers.
First, install the framework
The installation is successful, and the version is 1.11.28. The framework files are installed in the \python27\Scripts directory (just search for Scripts in the Python installation directory on your computer).
Create the project jinanwx (any name starts)
You can see the directory of the newly created project in the same directory
Enter python27\Scripts\jinanwx\jinanwx. Create our own module
The simple code written in jgotest01.py is as follows
The function of the module is to return a json format result.
Then you need to change the urls.py module
The catalog file is as follows
It's that simple, create a new file and modify another file, and it's done. Go back to the previous directory to start the service
Start successfully, try browser access