Skip to content

Hello

app.py
import surfra
greeting = None
@surfra.warmup
def load():
global greeting
greeting = "hello"
@surfra.handler
def predict(request: surfra.Request):
return {"text": f"{greeting} {request.input.get('name', 'world')}"}

Build it with the Python Dockerfile, push it, then deploy:

deploy.py
import surfra
app = surfra.App("hello")
app.deploy(
image="ghcr.io/you/hello:1",
entrypoint="app.py",
runtime={"engine": "python"},
autoscale={
"max_replicas": 1,
"providers": [{"provider": "salad", "gpu": "cpu", "vcpu": 2, "ram_gb": 4, "priority": 1}],
},
)
print(app.run({"name": "Surfra"}, timeout=600))
# {'text': 'hello Surfra'}