Hello
import surfra
greeting = None
@surfra.warmupdef load(): global greeting greeting = "hello"
@surfra.handlerdef predict(request: surfra.Request): return {"text": f"{greeting} {request.input.get('name', 'world')}"}Build it with the Python Dockerfile, push it, then deploy:
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'}