christabor / flask_jsondash

:snake: :bar_chart: :chart_with_upwards_trend: Build complex dashboards without any front-end code. Use your own endpoints. JSON config only. Ready to go.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Using the example app

FMFluke opened this issue · comments

I am sorry if this sounds stupid, but I am new to flask development. I am confused with how exactly to use the example app to study how the flask_jsondash work. I run the app and click the link that said 'Visit the chart blueprints' but it lead to server timeout error. When I looked at the code I understand that there is no function mapped to '/charts' URL, I guess you want people to implement that themselves but I can't figure out what I need to do. The doc seems to be built so people with experiences can understand quickly, but I can't. Do you have some guideline for people who are new to this? Specifically, I would appreciate a newbie tutorial. It does not have to be detailed, but a steps that I can follow to understand more easily.

Check out https://github.com/christabor/flask_jsondash/blob/master/README.md#usage to get started. There is a prebuilt example app that has the routes and blueprint already wired up. I would recommend cloning and running the example app as a first step, but all three options will work.

Feel free to post any more questions you have.

I did everything listed in the first option (cloning, creating virtual environment, running the app) and access the page on port 8080. I did not edit any single thing in any source code files since I assumed the example app should be working as-is. When I clicked the link 'Visit the chart blueprints', however, an error occurred that says ServerSelectionTimeoutError: localhost:27017: [Errno 61] Connection refused. That is why I asked the question in the first place. Any idea as to what is happening or what necessary steps I should take first before I run the app? I am guessing there is something to do with mongodb, looking at the port number 27017. (I noticed that is your default for db port.) But I don't know what exactly I need to do.

Thanks for the info @FMFluke.

The problem is that mongo is not running. You will need to make sure mongo is installed (for example, brew install mongo for mac, or apt-get install mongo for Ubuntu - for other clients, see https://www.mongodb.com/ for more)

Once mongo is installed, you will need to make sure it's running (e.g. mongod on the command line), and make sure you have a database and collection setup. I recommend a tool like RoboMongo if you are not comfortable on the command line.

Here are some more resources: https://www.tutorialspoint.com/mongodb/mongodb_create_database.htm

Yes, I can now get the app running. I don't know how did I overlook that, but maybe you should highlight this on the read above the usage steps too to make people remember to start their mongo first. If I have more question I will post it later, thank you.

Good to hear! Reopen if needed.

Do you have any advice if I want to connect to REST API endpoints which required OAuth 2.0? Or is it easier to have a separate app implementing the Authentication process, obtaining the session token and pull the data first and then supply it to the dashboard?

You can implement it directly in your flask app with something like https://github.com/mitsuhiko/flask-oauth or https://github.com/lepture/flask-oauthlib. Your routes can then return whatever data you want.

For flask-oauthlib, there are plenty of examples on how to do this in a flask app here: https://github.com/lepture/flask-oauthlib/tree/master/example