stitchfix / pyxley

Python helpers for building dashboards using Flask and React
MIT License
2.27k stars 257 forks source link

problem running the basic app #54

Closed disimone closed 7 years ago

disimone commented 7 years ago

Hi,

first of all, thanks for providing this code.

I am new to pyxley, and I was trying to run the basic app described in docs/basic.rst.

Btw, it would be really great if the instructions could be made idiot proof, for example by explicitely saying that index.html must be manually created and filled with the simple div, and that one needs to manually "bower install pyxley". At least , I did that, I hope it's not wrong :)

Once this is done, I still cannot run the example, with npm complaining that a package.json is not found in my top folder (what is called "App" in the dcumentation).

I also noticed that my top folder has no bower.json file, and it should be there according to the documentation (although it is unclear how it gets there)

Am I missing anything?

Kind regards,

Andrea.

nmkridler commented 7 years ago

Thanks Andrea!

Apologies, I haven't had a chance to update that doc yet. I've been trying to move to something more shiny-like that doesn't require all the boilerplate of starting a flask app.

The examples are all much more streamlined now. I wrote a gist to cover some of the changes. Originally I was using PyReact to transpile the jsx code into javascript at runtime. Then PyReact was deprecated, so I introduced some wrappers for webpack and npm to build a javascript bundle. I felt like this was a big pain and a huge barrier to entry, so I've been thinking about how to rework it. What I settled on was including the basic components to get an app running.

If you look in the plotly example under project/__init__.py this is what you will see. I've included a simple index.html in the latest version and a javascript bundle. The locations are provided in the default_static_path and default_template_path functions. There's a file in the directory called buildui.py that does the normal pyxley stuff of creating a UILayout. Instead of writing a bunch of templated javascript file, the app just sends the props as JSON.

from os import path
from buildui import get_layouts

from pyxley.utils import create_app, default_static_path, default_template_path

# create the flask app
here = path.abspath(path.dirname(__file__))
app = create_app(here, default_static_path(), default_template_path())

# build the layout
get_layouts(app, here+"/fitbit_data.csv")

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

If you want to do something more custom and build your own javascript bundle, I suggest looking at the tests folder. I've made an app that renders all of the widgets in different tabs.

I'll try to get to updating the documentation soon. Sorry for the confusion!

disimone commented 7 years ago

Hi,

thanks a lot for the reply. I can fully agree on the "big pain" argument :)

The example you mention looks indeed a lot better, and it runs without problems.