Is there a simple way to distribute a Flask server as an executable?

advertisements

I'm building some simple editors with Backbone.js, and I'm hoping to be able to distribute them as apps for users to edit content in a mostly client-side way (i.e., I don't want users to have to futz with setting up stuff like MySQL or Apache).

So I was imagining a scenario like:

  1. User downloads a .zip file
  2. In the resulting opened folder, the user clicks index.html
  3. That opens in a browser
  4. Backbone app starts, stores data in localStorage
  5. The user can then export to CSV.

Believe it or not, that would solve my problem: I want to help users edit data in a browser and then get it back out in a familiar format (CSV can be loaded into Excel, for instance).

And I’d like to do this without forcing them to configure a server. It seems like this is almost possible in the HTML5 stack. However, in at least one browser (Chrome), this doesn't work, because I get errors like this one:

XMLHttpRequest cannot load file:///users/me/project/data/Appdata.json. Origin null is not allowed by Access-Control-Allow-Origin.

(Oddly enough, I don't get that error in Firefox, and the .js or .json files load fine.)

So at this point it seems to me that there's no way around having these users use something kind of local server to serve up the Backbone interface.

So, I'm trying to figure out how to build a distributable, cross-platform executable that will allow my users to start a Flask server. (I hope to build a REST backend to a Backbone.js app.)

Is this wishful thinking? I'm assuming I can get the people in question to install Python.

Is this doable? There seem to be many ways to package up Python programs, (pyinstaller? py2exe? ...) So I thought I would ask here in case someone might know of a solution for the stack I have in mind.

TIA!


You can use Anthony Gordon McMillan’s Pyinstaller or Tuininga’s cx_Freeze

Quoting the PyInstaller website:

Features

Packaging of Python programs into standard executables, that work on computers without Python installed.

Multiplatform: works under

  • Windows (32-bit and 64-bit),
  • Linux (32-bit and 64-bit),
  • Mac OS X (32-bit only, 64-bit in git, see Features/MacOsCompatibility) and experimentally Solaris and AIX (in git).

Multiversion: works under any version of Python from 2.2 up to 2.7.