Reply
Test your front-end's calls easily!
Description
Have you ever been in a situation where you were making a front-end or mobile app which needed to comunicate to a server?
I think we've all been there.
The problem comes when the server isn't available at that particular moment or it hasn't even been programmed yet.
Here comes Reply!
With Reply you can make a simple testing server in a matter of seconds.
Let me show you how
Installation guide
Reply is on PyPy, so you can install it like this:
pip install reply
That's it!
Complete guide
We'll explore the several options that Reply brings us:
Server creation
You can create a server called "example" like this:
python -m reply make example
This will prompt you something like:
----Welcome to Reply!----
In which port do you want the server to run on?
>
As I want the server to run on port 8080 I'll enter that
Then, It'll ask to add some endpoints. I'll add only one:
/hello
Which will return:
helloworld
when called.
I add them like this:
Enter endpoint's relative url (/for/example):
> /hello
Enter example response ({status: "connected"}):
> helloworld
For the purpose of this example I'll keep it simple with only this endpoint.
After that, It will show the overall info. Check it and if everything is OK, you should have a new file called example.json with this content:
{
"port": "8080",
"endpoints": [
{
"url": "/hello",
"response": "helloworld"
}
]
}
Yiay! We got our first server!
Running the server
OK, now we have our JSON file with our server's configuration (you can modify it directly if you want)
Running the server is as simple as
python -m reply run example.json
And... that's it! All petitions to the server will be logged to the console.
Now, if we go to
http://localhost:8080/hello
As a Reply.
Making a standalone server
If you are part of a team and don't want to make everybody install Reply (although recommended), you can make a standalone .py serverfile ready to share!
You only have to use the -s
flag when making the server, like this:
python -m reply make example -s
The proccess is the same as always, but the file resulting will be example.py
and will contain the standalone server.
Just run it like you'd normally run a python's script:
python example.py
And there you go!