Redis Shortest Introduction (3) API in 5 minutes even in Python

Python is a little more refreshing, but The URL is not refreshing. Whoever you like.

sudo yum -y install python pip pip install redis

mkdir api; cd api

Edit ./cgi-bin/get.py as below (Put it under cgi-bin of python 2 system and execute permission chmod + x is required)

python -m CGIHTTPServer &

curl http://0.0.0.0:8000/cgi-bin/get.py?id="key"

{"items": "value"}

get.py


#!/usr/bin/python
# coding: utf-8

import redis
import json
import cgi

form = cgi.FieldStorage()
print 'Content-Type: text/html\n\n'
if form.has_key("id"):
    id=form["id"].value
    r=redis.Redis()
    value=r.get(id)
    print json.dumps({'items':value})

Recommended Posts

Redis Shortest Introduction (3) API in 5 minutes even in Python
[Introduction to Algorithm] Find the shortest path [Python3]
Redis Shortest Introduction (3) API in 5 minutes even in Python
Evernote API in Python
C API in Python 3
Design Patterns in Python: Introduction
Implement Redis Mutex in Python
Redis pipe lining in Python
Blender Python API in Houdini (Python 3)
Getting the arXiv API in Python
Hit the Sesami API in Python
Create Gmail in Python without API
Hit the web API in Python
Quickly implement REST API in Python
[Introduction] Insert line breaks in Python 3
Mouse operation using Windows API in Python
[Introduction to Python] How to use class in Python?
Try using the Wunderlist API in Python
General Theory of Relativity in Python: Introduction
Try using the Kraken API in Python
Tweet using the Twitter API in Python
Get Google Fit API data in Python
Get Youtube data in Python using Youtube Data API
[Python] Pandas to fully understand in 10 minutes
Quickly try Microsoft's Face API in Python
Do something like Redis transactions in Python
Try hitting the YouTube API in Python
Project Euler # 2 "Even Fibonacci Numbers" in Python
Introduction to Vectors: Linear Algebra in Python <1>
Introduction to Effectiveness Verification Chapter 1 in Python
Receive websocket of kabu station ® API in Python
tse --Introduction to Text Stream Editor in Python
Try using the BitFlyer Ligntning API in Python
Get image URL using Flickr API in Python
I wrote "Introduction to Effect Verification" in Python
Tips for hitting the ATND API in Python
Let's judge emotions using Emotion API in Python
[Introduction to Algorithm] Find the shortest path [Python3]
[WP REST API v2] Upload images in Python
Hit the Firebase Dynamic Links API in Python
Introduction to Effectiveness Verification Chapter 2 Written in Python
[Docker] Create a jupyterLab (python) environment in 3 minutes!
Try using ChatWork API and Qiita API in Python
[Introduction for beginners] Working with MySQL in Python
Try using the DropBox Core API in Python
Quadtree in Python --2
Python in optimization
CURL in python
Metaprogramming in Python
Python 3.3 in Anaconda
Geocoding in python
Introduction of Python
SendKeys in Python
Meta-analysis in Python
Unittest in python
Epoch in Python
Sudoku in Python
DCI in Python
quicksort in python
nCr in python
N-Gram in Python
Programming in python