CherryPy

18.10.0 · active · verified Mon Apr 13

CherryPy is a pythonic, object-oriented HTTP framework that enables developers to build web applications in much the same way they would build any other object-oriented Python program. It includes a robust, HTTP/1.1-compliant, WSGI thread-pooled webserver. The library, currently at version 18.10.0, has a proven track record of stability and is actively maintained with several minor releases per year.

Warnings

Install

Imports

Quickstart

This minimal example demonstrates a 'Hello World' application. Define a class with a method (e.g., `index`) and decorate it with `@cherrypy.expose` to make it accessible via a URL. Then, start the CherryPy server using `cherrypy.quickstart()` with an instance of your application class.

import cherrypy

class HelloWorld(object):
    @cherrypy.expose
    def index(self):
        return "Hello World!"

if __name__ == '__main__':
    # By default, CherryPy binds to 127.0.0.1:8080 (localhost)
    # To make it accessible from other machines, set 'server.socket_host' to '0.0.0.0'
    # cherrypy.config.update({'server.socket_host': '0.0.0.0'})
    cherrypy.quickstart(HelloWorld())

view raw JSON →