Install virtualenv and create a virtual environment.
pip install virtualenv
virtualenv venv --python=python3
source ./venv/bin/activate
Install uWSGI and Falcon framework
pip install uwsgi
pip install falcon
Open an editor and save the code below as app.py
import falcon
class OneResource(object):
def on_get(self, req, resp, site_id):
resp.status = falcon.HTTP_200
resp.body = ('Hello Falcon, {}'.format(site_id))
app = falcon.API()
one = OneResource()
app.add_route('/v2/{site_id}', one)
app.add_route('/v1/', one)
Run uWSGI.
uwsgi --virtualenv venv --http :9090 --wsgi-file app.py --callable app
Check the result.
curl http://localhost:9090/v2/abc
curl http://localhost:9090/v1?site_id=abc
References:https://falcon.readthedocs.io/en/stable/user/tutorial.html