Sometimes you want to make your python package usable for different situations, e.g. flask or bottle or django.
If You want to minimize dependencies You can use an optional dependency in setup.py:
'flask': ['Flask>=0.8', 'blinker>=1.1']
Now you can install the library with:
pip install raven[flask]
Flask is a micro web framework which is really fun to use. With the following snippet You have a complete web app working within seconds.
from flask import Flask # 1
app = Flask(__name__) # 2
@app.route('/') # 3
return 'Hello World!'
if __name__ == '__main__':
All this snippet does is
- Importing the Flask module,
- Creating the app,
- Defining an so called endpoint and finally
- Running the web app in a container.
Flask brings its own WSGI server called “werkzeug”. Please use it just for development purposes. It is not suitable for live applications. Continue reading “Bringing AJAX to Flask – Part 1”