The following article mainly describes the steps of the Python RUD function in the actual application process and the code examples of the Python RUD function. The following article describes the related content, we hope that you will gain some benefits after browsing our articles.
Recently, a new http rest service needs to be implemented internally, and the data is in JSON format. I plan to use Python as a prototype to compare the specific differences with the Java implementation scheme. I have no practical experience in Python before, so the process is as follows.
First, define the Protocol. Suppose we want to implement a service managed by a group member.
Add members:
- POST http://server/group-user/<group-id>
- users=[1,2,3...]
Delete a member:
- DELETE http://server/group-user/<group-id>
- users=[1,2,3...]
Finally, obtain the members.
After evaluating several python web frameworks, including django, selector, and CherryPy. After installing and reading some documents, Django finds that it is similar to ruby on rails and is a fast MVC/ORM framework, which is not suitable for a lightweight REST service.
There are too few selector documents, and it seems complicated to use the Python RUD function to provide a much simpler REST service. There are few discussions on the Internet, and there may be no large-scale applications in the REST mode. When I was confused, I saw the introduction of web. py. After trying it out, I found that it was the most suitable and easy to use. POST, GET, DELETE, and PUT must be implemented in the corresponding function. In addition, classes are required for common web applications such as db, form, and http. The above article introduces the Python RUD function REST service.