Three steps to implement the Python RUD Function

Source: Internet
Author: User

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:

 
 
  1. POST http://server/group-user/<group-id> 
  2. users=[1,2,3...] 

Delete a member:

 
 
  1. DELETE http://server/group-user/<group-id> 
  2. 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.


 

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.