Is it difficult to create a restful style API interface? Obviously 5 minutes will do

Is it difficult to create a restful style API interface? Obviously 5 minutes will do!

1. Thinking

01. Is it difficult to create an API interface?

Is it difficult to create a restful style API interface?  Obviously 5 minutes will do

 

software testing engineer:

◆ Only tested the API interface, never created it

◆ You should master a back-end development language and back-end development framework! ?

◆ The brain capacity is limited, it's scary to think about it

02. How to create an API interface?

◆ Use Django restframework to quickly create a restful style API interface

◆ The serializer and view set provided by the Django restframework framework can be easily implemented

◆ Simple and efficient, low learning cost

2. Build the project

Is it difficult to create a restful style API interface?  Obviously 5 minutes will do

 

01, create a project

◆ Open pycharm

◆ Create project

Is it difficult to create a restful style API interface?  Obviously 5 minutes will do

 

◆ Use Douban source to install Django Django restframework markdown

Is it difficult to create a restful style API interface?  Obviously 5 minutes will do

 

◆ Create a Django project

Is it difficult to create a restful style API interface?  Obviously 5 minutes will do

 

◆ Run python manage.py runserver in Terminal, visit in the browser, if the following page appears, it means success

Is it difficult to create a restful style API interface?  Obviously 5 minutes will do

 

Three, create an API interface

Is it difficult to create a restful style API interface?  Obviously 5 minutes will do

 

01, create a sub-application and migrate

Is it difficult to create a restful style API interface?  Obviously 5 minutes will do

 

Is it difficult to create a restful style API interface?  Obviously 5 minutes will do

 

02, add configuration


Add the following configuration in CreateRestfulAPI/settings.py:

Is it difficult to create a restful style API interface?  Obviously 5 minutes will do

 

03, write code

◆ Create users/serializers.py file

Is it difficult to create a restful style API interface?  Obviously 5 minutes will do

 

◆ Add the following code in users/views.py

Is it difficult to create a restful style API interface?  Obviously 5 minutes will do

 

◆ Create sub-route users/urls.py file

Is it difficult to create a restful style API interface?  Obviously 5 minutes will do

 

◆ Add the following code in the global routing file CreateRestfulAPI/urls.py

Is it difficult to create a restful style API interface?  Obviously 5 minutes will do

 

◆ Create super administrator user

Is it difficult to create a restful style API interface?  Obviously 5 minutes will do

 

◆ Run the project

Enter at the command line: python manage.py runserver

04. Effect display

◆ Visit the homepage

Is it difficult to create a restful style API interface?  Obviously 5 minutes will do

 

◆ Log in as a super administrator user

Is it difficult to create a restful style API interface?  Obviously 5 minutes will do

 

◆ Manage users (POST, GET)

Is it difficult to create a restful style API interface?  Obviously 5 minutes will do

 

◆ Manage users (GET, PUT, DELETE)

Is it difficult to create a restful style API interface?  Obviously 5 minutes will do

 

Four, summary

Is it difficult to create a restful style API interface?  Obviously 5 minutes will do

 

◆ This article introduces a method to create an API interface conforming to the Restful style

◆ Including the construction of Django project environment

◆ Realize the creation method of GET, POST, PUT, DELETE interface, simple and efficient

◆ This article is excellent and original, there are deficiencies, please advise!

Recommend a software testing learning exchange group: 785128166, there are shared videos, interview guidance, test materials, mind maps, and videos in the group. They are all dry goods, you can download and watch. Mainly share test foundation, interface test, performance test, automated test, TestOps architecture, Jmeter, LoadRunner, Fiddler, MySql, Linux, resume optimization, interview skills, and actual video data of large-scale test projects. Use every minute and every second of your time to learn to improve yourself, and don't use "no time" to conceal your mental laziness! Try hard while you are young, and give your future self an explanation!

Public number: Programmer Erhei, after paying attention, you can receive a large amount of learning materials for free.

Good things should be shared with friends
 
 

Guess you like

Origin blog.csdn.net/weixin_53519100/article/details/114645854