project create
command to create a new directory and files for your project.
httpbin
to retrieve the IP address and test the code locally.
Change directories to the project directory and open the src/handler.py
file in your text editor.
httpbin
to get the IP address of the machine your code is running on.
Run this code locally to get the IP address of your machine, for example:
project dev
command.
Runpod provides a development server that allows you to quickly make changes to your code and test these changes in a live environment. You don’t need to rebuild a Docker image or redeploy your code to the Runpod platform just because you made a small change or added a new dependency.
To run a development server, use the Runpod CLI project dev
command and select a Network volume.
requirements.txt
.
When the Pod is running you should see the following logs:
[lug43rcd07ug47]
is your Worker Id. The https://lug43rcd07ug47-8080.proxy.runpod.net
is the URL to access your Pod with the 8080 port exposed. You can interact with this URL like you would any other Endpoint.
curl
command to fetch the IP address from the development server. You’ll learn how to include dependencies in your project and how to use the Runpod API to run your code.
You might have noticed that the function to get an IP address uses a third-party dependency requests
. This means by default it’s not included in Python or the Runpod environment.
To include this dependency, you need to add it to the requirements.txt
file in the root of your project.
runsync
method on the Runpod API to run your code synchronously.
The previous command returns a response:
project deploy
command. This will make your code available as a Serverless Endpoint.
Stop the development server by pressing Ctrl + C
in the terminal.
To deploy your code to the Runpod platform, use the Runpod CLI project deploy
command.
curl
command to fetch the IP address from the deployed Serverless function. You’ll see how your code runs as expected and tested in the development environment.
When the deployment completes, you can interact with your Endpoint as you would any other Endpoint.
Replace the previous Endpoint URL and specify the new one and add your API key.
Then, run the following command: