Serverless computing is a way of running code without having to worry about managing servers. It’s different from traditional server-based architectures because you don’t have to worry about provisioning or managing servers. Instead, you just write your code and deploy it to a serverless platform.
Vercel is a serverless platform that makes it easy to deploy and scale your code. To get started with Vercel, you first need to create an account. Then, you can create a new project and deploy your code.
APIs are a way for different applications to talk to each other. They’re like a waiter who takes your order at a restaurant and then brings you your food. In the case of APIs, the waiter is the API and the restaurant is the application that you’re using.
The Requests library is a Python library that makes it easy to interact with APIs. You can use it to send HTTP requests to APIs and get back data. For example, you could use Requests to send a GET request to an API that returns the weather forecast for your city.
import requests
url = “https://api.openweathermap.org/data/2.5/weather?q=London&appid=YOUR_API_KEY”
response = requests.get(url)
if response.status_code == 200: data = response.json() print(data[“weather”][0][“description”]) else: print(“Error: “ + response.status_code)
Sign up with Vercel
Create a repo in GitHub and connect it to Vercel
use requests
library to interact with REST Countries API
Create a serverless function following Vercel’s get-started directions that handles two kinds of queries:
GET
http request iwht a given country name that responds with a string with the form ‘The capital of X is Y’
GET
http request with a given capital that responds with a string with the form ‘The capital X is Y’