I need a simple Web server framework, and I have already used CherryPy in the past - so why not again ?
It is easier to place your Web Server config into 1 file. This file is called app.cfg, but you could have one for test and another for production.
[global] server.socket_host: '127.0.0.1' server.socket_port: 8001 log.error_file: 'site.log' [/] tools.staticdir.root = os.getcwd() [/static] tools.staticdir.on = True tools.staticdir.dir = "static" [/css] tools.staticdir.on =True tools.staticdir.dir = "css"
I need to start the Web Server - I do this as simply as possible.
import cherrypy import os from escp import webserver cherrypy.quickstart(webserver(), '/', 'app.cfg')
Again I just need a framework.
import cherrypy class webserver(object): def __init__(self,index="test",field="_all"): self.index=index self.field=field @cherrypy.expose def index(self): return "Hi there" @cherrypy.expose def generate(self): return 'Hi there this is a new entry point' @cherrypy.expose def help(self): html=""" <H2> This is an ElasticSearch Web Engine. </H2> It has been designed to allow easy querying of an ES data set. """ return html
And we get back
<H2> This is an ElasticSearch Web Engine. </H2> It has been designed to allow easy querying of an ES data set.