Learning Falcon

Learning Falcon

2018-01-13. Category & Tags: Python, Falcon, API

A great 5-video tutorial: 35minutes on YouTube (6 tomatoes / 2.5 hours for non-stop studing by coding). Author’s Github (py2), My Github (py3).

Differences in my Github code:

  • py3, not py2
  • using on_put() to test validity of input json from client
  • using on_delete() to test params (just to test, should NOT be used in real-world)
  • using another route /test2?x=1&y=3 to test params

Usage in Nix:

pip3 install falcon gunicorn
gunicorn app:api # in the folder of app.py

Usage in Win (tested in bash sub system):

pip3 install falcon waitress
waitress-serve --port=8000 app:api

The json content that is sent from client:

{
	"method": "get-name",
	"name": "Sunny",
	"x": "22",
	"y": 33,
	"x1": 11,
	"y1": "55"
}

Note: string-number is suggested in json instead of int/float directly, to avoid different formats of big numbers.

See restful api for testing clients.


The insomnia client is used, (Postman is too slow, SoapUI has not been tested).

Routers: see github discussion

To deploy with Nginx on Ubuntu 16.04: ref-DigitalOcean

The official quick-start example is also very easy (they are using a static long-life object which is good for caching data).is good for caching data).