1. 程式人生 > >HTTP endpoints for your apps | Anvil

HTTP endpoints for your apps | Anvil

« Anvil Blog
New: Make an API for your Anvil app

Sometimes we want to connect other programs with our Anvil apps. Whether it’s a native mobile app, a shell script, or a web service like Twilio, most things expect to make REST or plain HTTP requests.

As of today, this is all it takes to publish an HTTP API that returns some JSON:

@anvil.server.http_endpoint("/greet/:name")
def greet(name, **qs):
  return {'message': 'Hello, ' + name + '!'}

We can demonstrate it with the curl command-line program:

$ curl https://http-endpoint-demo.anvilapp.net/_/api/greet/Joanne
{"message":"Hello, Joanne!"}

Learn More

Get the best out of Anvil with our free email course.