Sometimes I run into the need to build a quick test service, like this.
Build an HTTP Service, which can be run locally, but also needs to be accessible on the public network, and request the service to get a custom set of JSON data. For no other reason than to be able to use it for testing quickly.
At this time I want to complete in the shortest possible time, such as a minute to write it, how can I do this time?
For example, you might think of running Flask or FastAPI, changing the sample code, and then running it with a single Python command.
For example, the code looks like this.
Then I ran it with the command.
OK, the promised custom JSON has been completed.
But I need to add requirements, I need to support cross-domain access, how do I do that? At this point I may have to search for the FastAPI cors keyword again, and then find the https://fastapi.tiangolo.com/tutorial/cors/ documentation, and then add some configuration like this.
It’s okay, right?
So now I’ve changed my requirements. What if I want to return an image? What if I want to return a file? What if I want HTTPS access?
Or even say, I am not familiar with the code written what to do? In order to get this API Service I have to spend most of an hour, too much to lose it.
After all, everyone is quite busy.
So I would think, these simple things, why write code to solve ah? Is there no tool to do it through some visual configuration?
If you also have this trouble, please continue to look down.
So now my need is: I want to quickly build an API Server with a convenient tool that can be configured to return JSON or images or files and so on, or even say dynamic routing, dynamic forwarding and so on, and it would be nice if these steps could also be done through a visual graphical interface.
Here we go, today we recommend a tool called
Mockoon is a tool that can help us quickly build API services through a graphical interface, supporting data simulation, route resolution, cross-domain access, HTTPS, custom delay, Docker, and all kinds of features you want, while supporting
Linux, the overall page looks like this.
The layout is similar to PostMan.
For example, on the left side we can configure a list of requests, and on the right side we can configure details such as whether it is a GET or POST request, what the path is, what the Response Body is, what the Response Headers are, and also some rules and basic settings.
In addition, at the top I can configure the running host and port, and then there is a run button in the upper left corner, a click is equivalent to start the Server, after starting the button will turn red, and then press it to stop, for example, here I have configured to run on the local 3894 port.
Then I modified Body.
Here I return a list in JSON format, containing three fields.
Then I’m going to configure cross-domain access by adding a Response Header.
Then click the Run button in the upper-left corner and you are done.
Mockoon also provides a shortcut access, then tap the Open button in the upper right corner.
The browser then opens and you can see the data.
In this way, we have completed the construction of the API Server through a very simple visual configuration, if skilled a minute to complete.
In addition, there are too many functions, such as HTTPS, multi-request processing, logging, routing, template configuration here is not to describe one by one, when used to check the documentation on it!
- Import/Export Data：https://mockoon.com/docs/latest/import-export-data/
- Mutiple Response: https://mockoon.com/docs/latest/multiple-responses/
- Proxy Mode: https://mockoon.com/docs/latest/proxy-mode/
- Request logging: https://mockoon.com/docs/latest/requests-logging/
- Response Headers: https://mockoon.com/docs/latest/response-headers/
- Routing: https://mockoon.com/docs/latest/routing/
- Templating: https://mockoon.com/docs/latest/templating/
In addition, Mockoon also supports command line, for example, you can quickly create an API Server by using mockoon-cli, as shown in the figure.
Command line usage and installation can be found at: https://github.com/mockoon/cli#installation
The above is a brief introduction to this tool, more features waiting for your exploration!