Web API with Python + Falcon

If you try to do a little Web API with Python ...

Just the right article was published. Python --Building a speed of light Web API server with Falcon --Qiita

Falcon - The minimalist Python WSGI framework falconry/falcon

In this article, it was written using simple_server, but here I will use the recommended Gunicorn. Gunicorn - Python WSGI HTTP Server for UNIX benoitc/gunicorn

Installation

All together with pip

pip install --upgrade cython falcon gunicorn

sample

Falcon Web Framework (http://falconframework.org) With reference to

sample.py


# -*- coding: utf-8 -*-
# sample.py
import falcon
import json

class ItemsResource:
    def on_get(self, req, resp):
        """Handles GET requests"""
        items = {
            'title': 'Python+Web API with Falcon',
            'tags': [
                {
                    'name': 'Python','versions':[]
                },
                {
                    'name': 'Falcon','vresions':[]
                }
            ]
        }

        resp.body = json.dumps(items,ensure_ascii=False)

api = falcon.API()
api.add_route('/items', ItemsResource())

When you access with wget http: // localhost: 8000 / items

{"tags": [{"name": "Python", "versions": []}, {"vresions": [], "name": "Falcon"}], "title": "Python+Web API with Falcon"}

I heard that I was able to get it safely. I'm happy.

Recommended Posts

Web API with Python + Falcon
Explosive speed with Python (Bottle)! Web API development
Create an API server quickly with Python + Falcon
Use Trello API with python
Web scraping with python + JupyterLab
EXE Web API by Python
Play RocketChat with API / Python
Call the API with python3.
Web application with Python + Flask ② ③
Use subsonic API with python3
Web scraping beginner with python
Streamline web search with python
Web application with Python + Flask ④
Web scraping with Python ① (Scraping prior knowledge)
Get reviews with python googlemap api
Run Rotrics DexArm with python API
Getting Started with Python Web Applications
Web scraping with Python First step
I tried web scraping with python.
Monitor Python web apps with Prometheus
Quine Post with Qiita API (Python)
Get web screen capture with python
Hit the Etherpad-lite API with Python
[python] Read information with Redmine API
Hit the web API in Python
[SAP CP] Web API created with python in CF environment
Build a speed of light web API server with Falcon
Collecting information from Twitter with Python (Twitter API)
[Python] Web application from 0! Hands-on (3) -API implementation-
FizzBuzz with Python3
Scraping with Python
Automatically create Python API documentation with Sphinx
WEB scraping with Python (for personal notes)
Statistics with python
Simple Slack API client made with Python
Scraping with Python
Retrieving food data with Amazon API (Python)
Python: Reading JSON data from web API
Python with Go
Getting Started with Python Web Scraping Practice
Twilio with Python
Integrate with Python
Play with 2016-Python
AES256 with python
Create REST API that returns the current time with Python3 + Falcon
Daemonize a Python web app with Supervisor
Tested with Python
[Personal note] Web page scraping with python3
python starts with ()
Web scraping with Python ② (Actually scraping stock sites)
Download files on the web with Python
Horse Racing Site Web Scraping with Python
[Python] A quick web application with Bottle!
with syntax (Python)
Getting Started with Python Web Scraping Practice
Easy web app with Python + Flask + Heroku
Bingo with python
Get US stock price from Python with Web API with Raspberry Pi
[Python] Quickly create an API with Flask
Zundokokiyoshi with python
Run a Python web application with Docker