Are you looking for my non-technical blog?

This is now my technical-only blog, my non-technical blog is here.

03 January 2012

A Waitress & A Flask

Flask is a microframework for Python based on Werkzeug, Jinja2, and here is a simple Flask Hello World code:

from flask import Flask
app = Flask(__name__)

@app.route("/")
def hello():
return "Hello World!"

if __name__ == "__main__":
app.run()

Waitress on the other hand is a pure-Python WSGI server, and here's normal usage of the server:

from waitress import serve
serve(wsgiapp, host='0.0.0.0', port=8080)

So, here is how I wrote code to run Flask from within a Waitress WSGI Server:

from flask import Flask
from waitress import serve

app = Flask(__name__)

@app.route("/")
def hello():
return "Hello World!"

if __name__ == "__main__":
#app.run()
serve(app)

Documentations:
http://flask.pocoo.org/docs/
https://github.com/Pylons/waitress/blob/master/docs/index.rst

No comments:

Post a Comment