Skip to main content

fireflask

I’ve long wanted to use FirePython for debugging Flask web apps, but could never seem to get it working right.

After a long time away, I circled back to it, and with help from the Flask folks, got it working smoothly.

Indeed, it was so simple to do, knowing the right invocation and configuration, that I can only blame myself for not getting it earlier. My only consolation is that there is no real documentation (the usage link on FireLogger’s home page is a dead link).

So, having figured it out, I’m sharing in the hopes that others can now simply use this beautiful tool.

http://content.screencast.com/users/jonathaneunice/folders/Jing/media/ca71bb7a-e383-4607-a66a-12a27f18208e/00000330.png

Basic Idea

The code is sufficiently simple I can put the core of it here:

from flask import Flask
from logging import DEBUG
from firepython.middleware import FirePythonWSGI, logging

app = Flask('appname')
app.wsgi_app = FirePythonWSGI(app.wsgi_app)
logging.getLogger().setLevel(DEBUG)

That’s it. Now you’re off to the races. When the app server is run, any logging messages you direct to the logging object end up in your FireBug / FireLogger console. More complete versions of this demo code can be found in trivial.py and demo_primitive.py in the repository.

FireFlask

To make things even simpler, the fireflask module requires just two lines of code (one to import fireflask, and one to put it into operation).

from flask import Flask
from fireflask import *

app = Flask('appname')
FireFlask(app)

@app.route('/')
def hello_world():

    logging.info('serving hello_world content')
    return 'Hello World!'

app.run()

Here we’ve completed the program with a function that provides content, and the startup code for the Flask web server. fireflask isn’t a huge lines-of-code savings, but it will save you a few steps and make the program cleaner.

Notes

  • This has been tested under Python 2.7. No promises are made for other versions of Python.

  • The author, Jonathan Eunice or @jeunice on Twitter welcomes your comments and suggestions.

Installation

To install or upgrade to the latest version of fireflask:

pip install -U fireflask

This will install the firepython module automatically. Or, if you want to use just the primitive approach:

pip install -U firepython

(You may need to prefix these with sudo to authorize installation.)

Use the standard Firefox tools to install FireBug and the FireLogger extension.

Use

To run the demonstration programs, run trivial.py, demo_primitive.py or demo.py.

Browse to 127.0.0.1:5000 in Firefox, with the FireBug extension turned on, and the Logger pane visible. This is the FireBug icon:

http://content.screencast.com/users/jonathaneunice/folders/Jing/media/795cbb0a-aa03-4d01-993f-4a1e4e2ce427/00000329.png

When FireBug is operational, it’s displayed in color, not grayed out. If you browse to the page before FireBug is turned on, you’ll need to reload the page to see the logged messages.

Metadata

Release files for fireflask 0.2.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distributions (sdists)

Source distribution for fireflask 0.2.0
File Size Uploaded
fireflask-0.2.0.zip 8.7 kB Details
fireflask-0.2.0.tar.gz 3.6 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for fireflask 0.2.0
File Interpreter ABI Platform
fireflask-0.2.0-py2.py3-none-any.whl Python 3, Python 2 none any Details

Total release size: 18.4 kB

Release files / fireflask-0.2.0.zip

Download URL fireflask-0.2.0.zip
Size 8.7 kB
Tags Source
SHA-256 checksum
How to use checksums
b0e7a8cf1d2d5c121100a086ed9940ab6364e6ddf1aa59ef2eff2f9de3467b53
BLAKE2b-256 checksum
How to use checksums
03e57bb055383772cea9ac959a55e5042f3d3ed513ac65e5c718fe270a2a309e
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Release files / fireflask-0.2.0.tar.gz

Download URL fireflask-0.2.0.tar.gz
Size 3.6 kB
Tags Source
SHA-256 checksum
How to use checksums
0d6318741010c9551dd480872c9483dab8598b2dc53d28b3e5123acec42262ba
BLAKE2b-256 checksum
How to use checksums
dcf29bbf8d743ce4116e99a4ffcf40a9cb1889d4a4eb52cc44fedfe1dbd0663c
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Release files / fireflask-0.2.0-py2.py3-none-any.whl

Download URL fireflask-0.2.0-py2.py3-none-any.whl
Size 6.0 kB
Tags Python 2 Python 3
SHA-256 checksum
How to use checksums
1c8c5ccbbd21c377d210b4ca8cd7b2c5c5f7523e4680bcf7ec3ffc3b4275c98b
BLAKE2b-256 checksum
How to use checksums
8d8ac0bbee7c7c2f5bf42a708a7649b5712fe3d34b4306d41f0ea08a30fa9ae7
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Release history Release notifications | RSS feed

This release

0.2.0 This release

3 release files

0.1.2

2 release files

0.1.1

2 release files

0.1

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page