Modal runs code in the cloud. You're charged only for the [[compute]] you use.
To set up modal for the first time in a [[Jupyter Notebook]], run the setup code in a cell.
```python
!modal setup
```
Modal supports [[infrastructure as code]] configuration. Here's a simple app that returns the user's location based on their IP address.
```python
import modal
from modal import App, Volume, Image
app = modal.App("hello")
image = Image.debian_slim().pip_install("requests")
gpu = "T4"
@app.function(image=image)
def hello() -> str:
import requests
response = requests.get('https://ipinfor.io/json')
data = response.json()
city, region, country = data['city'], data['region'], data['country']
return f"Hello from {city}, {region}, {country}!!"
with app.run():
reply=hello.local() # run locally
with app.run():
reply=hello.remote() # run remote
```
You'll notice that the location is different when running remotely rather than locally.
See also [[Google Cloud Functions]].