Build a speed of light web API server with Falcon

Falcon is a web application framework dedicated to building web API servers. If other frameworks are popular cars packed with rich features such as template engines and O / R mappers, Falcon is a F1 machine-like frame that focuses and refines only the features needed for a Web API server. It is a work.

Falcon Official Page

Notable is its simple design and overwhelming speed. The following is the benchmark posted on the official page (as of November 26, 2015, comparison result with PyPy 2.5.1).

benchmark.PNG

It runs at 27 times faster than Flask and 1.5 to 2 times faster than Bottle, which is said to be a simple framework.

It's also very easy to implement. The following is an example implementation of a server that returns a simple JSON response. If you execute it with python, the server will start up on port 8000, and when you access it, a JSON response will be returned.

example.py


import json
import falcon


class HelloResource(object):

    def on_get(self, req, resp):
        msg = {
            "message": "Welcome to the Falcon"
        }
        resp.body = json.dumps(msg)

app = falcon.API()
app.add_route("/", HelloResource())


if __name__ == "__main__":
    from wsgiref import simple_server
    httpd = simple_server.make_server("127.0.0.1", 8000, app)
    httpd.serve_forever()

There is another feature that allows you to implement a so-called Filter called Hook, but that's the basics. Since the Falcon application is a WSGI application, it can run on a WSGI server. In the above, the Python built-in simple_server is used, but it can also be run with gunicorn or waitress (officially recommends gunicorn, but I think that Windows people can not run it, so use waitress etc. I think it's good).

I think that it is suitable for the following situations.

We hope that you will try it out and experience its speed and ease of use.

Recommended Posts

Build a speed of light web API server with Falcon
Web API with Python + Falcon
Build a web application with Django
Build a Fast API environment with docker-compose
Build a web server on your Chromebook
Hit a method of a class instance with the Python Bottle Web API
Build a local server with a single command [Mac]
Start a simple Python web server with Docker
Launch a web server with Python and Flask
Explosive speed with Python (Bottle)! Web API development
Create an API server quickly with Python + Falcon
Source compile Apache2.4 + PHP7.4 with Raspberry Pi and build a Web server --2 PHP introduction
Source compile Apache2.4 + PHP7.4 with Raspberry Pi and build a Web server ―― 1. Apache introduction
[Part 2] Let's build a web server on EC2 Linux
Learning neural networks using Chainer-Creating a Web API server
CTF beginner tried to build a problem server (web) [Problem]
[Vagrant] Set up a simple API server with python
[python] [Gracenote Web API] A little customization of pygn
Source compile Apache2.4 + PHP7.4 with Raspberry Pi and build a web server --3. Use MySQL
Build API server for checking the operation of front implementation with python3 and Flask
Set up a web server with CentOS7 + Anaconda + Django + Apache
[Introduction to AWS] A memorandum of building a web server on AWS
Tornado-Let's create a Web API that easily returns JSON with JSON
Create a web API that can deliver images with Django
Create playlists of bright songs only with Spotify Web API
(For beginners) Try creating a simple web API with Django
[Study memo] Build GeoJSON vector tile server with Fast API
Output the result of morphological analysis with Mecab to a WEB browser compatible with Sakura server / UTF-8
[python, ruby] fetch the contents of a web page with selenium-webdriver
Build a Flask / Bottle-like web application on AWS Lambda with Chalice
I made a web server with Raspberry Pi to watch anime
Creating a Flask server with Docker
Build a deb file with Docker
A collection of one-liner web servers
Introduction and usage of Python bottle ・ Try to set up a simple web server with login function
A story that visualizes the present of Qiita with Qiita API + Elasticsearch + Kibana
Build a classifier with a handwriting recognition rate of 99.2% with a TensorFlow convolutional neural network
Development and deployment of REST API in Python using Falcon Web Framework
Build a CentOS Linux 8 environment with Docker and start Apache HTTP Server
Flask + PyPy I took a speed benchmark with Blueprint for large-scale Web
Summary of how to build a LAMP + Wordpress environment with Sakura VPS
Build a proxy server with nginx on multiple remote servers using Ansible
Build a Pypi cache server on QNAP
Easily build a DNS server using Twisted
Build a blockchain with Python ① Create a class
Set up a Samba server with Docker
Play like a web app with ipywidgets
Web server for browser testing with Mocha
Build a Tensorflow environment with Raspberry Pi [2020]
A memorandum of speed of arbitrary degree diagonalization
Build a simple WebDAV server on Linux
Daemonize a Python web app with Supervisor
Transcription of images with GCP's Vision API
Build a Samba server on Arch Linux
[Python] A quick web application with Bottle!
Create a simple web app with flask
Try speed comparison of BigQuery Storage API
[Linux] Build a jenkins environment with Docker
I tried to make a Web API
Run a Python web application with Docker
Build a python virtual environment with pyenv