Spaces:
Sleeping
Sleeping
File size: 766 Bytes
5fdb69e |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 |
import modal
from modal import App, Image
# Setup
app = modal.App("hello")
image = Image.debian_slim().pip_install("requests")
# Hello!
@app.function(image=image)
def hello() -> str:
import requests
response = requests.get('https://ipinfo.io/json')
data = response.json()
city, region, country = data['city'], data['region'], data['country']
return f"Hello from {city}, {region}, {country}!!"
# New - added thanks to student Tue H.!
@app.function(image=image, region="eu")
def hello_europe() -> str:
import requests
response = requests.get('https://ipinfo.io/json')
data = response.json()
city, region, country = data['city'], data['region'], data['country']
return f"Hello from {city}, {region}, {country}!!"
|