Before this section begins, fix the bugs.

When the interface request body is empty

We run debug SEND and exception tests, and we get an error.

The trick is to look at the last sentence, which is a JSON parsing error. And then when we’re looking for the exact line, we’ll just look at the py file that we wrote ourselves and ignore everything else. Quickly lock this line, it turns out to be header problem. We jsonize the header string directly in our code. The result, when null, raises an error.

So this is error handling of a user exception input that we missed earlier.

We can simply use a try:

Similar small bug may also have, we play their own skills, can be solved.

Then we test to find that we can handle the error result normally:

But there is a new problem when the header is not empty, but also does not conform to the dictionary/JSON format. How do we deal with that?

The try: json.loads() method doesn’t work anymore.

Because only if it is empty or contains an English string, the error will be caught, but if it is not empty, only pure numbers, such as: 21312313

This will not return an error, and then still not a dictionary, the following request will return an error!

Error for empty!

Not empty but illegal, incredibly not error!

I think we have many ways to solve this situation, and then write a judgment. Or just try the entire send request code.

In fact, can be, anyway, the equivalent of frequent patches ~

I tried this whole send request part. Then catch all kinds of exceptions and return to the front end, so that when we debug the interface error later, we can not look at the log, directly look at the interface return to know the problem. Of course, normal commercial software does not allow this, but we are in-house tools, and the users are IT engineers. Once and for all, but later we have enough time, or to continue to refine the processing of various exceptions, not such a try.

        

=============== gorgeous division =======================

Now start the formal content of this section, has been the most ridicule is this home page. Ugly and useless.

This is because we started simply to everyone as a papyrus for practice, now practice almost, you can use the present skills to do a home page.

As for the function and design of the home page, actually we have discussed it very early before. It’s all about what we want to do:

There are two mature and useful designs:

  1. Main push hyperlink portal.

The whole page is made into dozens or hundreds of hyperlinks composed of the matrix, convenient for the company’s colleagues to enter and save bookmarks, develop a habit of dependence, improve the use of viscosity, with the search, fast and other small design is very practical and beautiful.

2. Make it a professional tool for the interface test platform – home page debugging

The positioning of the interface test platform is actually a synthesis, not a simple challenge to replace a mainstream tool, but just integration. In order to successfully integrate the convenience of Postman, we need to introduce a quick debugging function on the home page. The interface satisfied with debugging can be saved in the project, and there is a historical playback function. In this way, it can reduce the tedious degree of use for new users, which is equivalent to the login of tourists in our APP mobile games, eliminating the trouble of registration, and registering after satisfactory trial play.

   

Both of these designs have been successful. Now the interface debugging function in the project has been basically completed, so we have the ability to complete the above two designs.

You can redesign your home page according to your own preferences.

However, only one can be explained and implemented in this tutorial.