From charlesreid1

(Created page with "To embed a Flask app inside a module: <pre> /yourlibrary /yourlibrary __init__.py some_code.py [...] /webapp __init__.py templates/ index.html ...")
 
No edit summary
Line 35: Line 35:


<pre>
<pre>
recursive-include yourapplication/templates *
recursive-include yourlibrary/templates *
recursive-include yourapplication/static *
recursive-include yourlibrary/static *
</pre>
</pre>

Revision as of 16:33, 5 July 2014

To embed a Flask app inside a module:

/yourlibrary
  /yourlibrary
    __init__.py
    some_code.py
    [...]
  /webapp
    __init__.py
    templates/
      index.html
      [...]

Then you will structure your setup.py like this:

config = {
    'description': 'foo',
    'author': 'bar',
    'version': '1.0',
    'install_requires': ['flask'],
    'packages': ['yourlibrary','webapp'],
    'include_package_data' : True,
    'scripts': [],
    'name': 'yourlibarary',
    'zip_safe' : False
}

setup(**config)

The include package data directive points setup.py to a manifest file called MAFIEST.in, which sits next to setup.py. That should have these lines:

recursive-include yourlibrary/templates *
recursive-include yourlibrary/static *