Coder Social home page Coder Social logo

davidalphafox / blog-sample-flask-charts Goto Github PK

View Code? Open in Web Editor NEW

This project forked from app-generator/sample-flask-charts-js

0.0 1.0 0.0 2.23 MB

Flask Charts - Flask-RestX and Charts.JS | AppSeed

Home Page: https://appseed.us

License: MIT License

Python 40.63% JavaScript 43.33% HTML 16.04%

blog-sample-flask-charts's Introduction

Flask Charts via Flask-RestX

Sample project crafted with Flask, Flask-RestX and Charts.JS - provided by AppSeed

This is a sample code to showcase how to plot charts using Flask as the backend framework. Frontend uses Bootstrap5 for styling and Chart.js for dynamic charts. The dataset is loaded via a custom Flask CLI and the project homepage showcases three charts type: line, bar and pie.



Features:

  • Up-to-date dependencies
  • Stack: Flask
  • API: Flask-RestX
  • DB Tools: Flask-SqlAlchemy, SQLite
  • Charts: Charts.js

Flask Charts via Flask-RestX and Charts.js - provided by AppSeed.us

โœจ How to use it

๐Ÿ‘‰ Clone Sources (this repo)

$ git clone https://github.com/app-generator/blog-sample-flask-charts.git
$ cd blog-sample-flask-charts

๐Ÿ‘‰ Install Modules using a Virtual Environment

$ virtualenv env
$ source env/bin/activate
$ pip3 install -r requirements.txt

Or for Windows-based Systems

$ virtualenv env
$ .\env\Scripts\activate
$
$ # Install modules - SQLite Database
$ pip3 install -r requirements.txt

๐Ÿ‘‰ Set up the environment

$ export FLASK_APP=app.py
$ export FLASK_ENV=development

Or for Windows-based Systems

$ # CMD terminal
$ set FLASK_APP=app.py
$ set FLASK_ENV=development
$
$ # Powershell
$ $env:FLASK_APP = ".\app.py"
$ $env:FLASK_ENV = "development"

๐Ÿ‘‰ Load Sample Data from data directory

  • monthly_customers.csv
  • monthly_sales.csv
  • product_sales.csv
$ flask load-data 

๐Ÿ‘‰ Start the APP

$ flask run 

โœจ Code-base structure

< PROJECT ROOT >
   |
   |-- app.py            # Create and start the APP object
   |-- api.py            # Simple API node 
   |-- models.py         # app models
   |
   |-- data_loader.py    # Save the data in DB
   |
   |-- templates
   |    |-- index.html   # Simple page styled with BS5 
   |
   |-- static
   |    |-- js/custom.js # Code the Charts
   |
   |-- *******************

The bootstrap flow

  • app.py
    • bundles all resources
    • serve the index.html
  • api.py exposes a simple API using the DB data
  • templates/index.html
    • HOMEpage of the project
  • js/custom.js
    • fetch data exposed by the API


Flask Charts via Flask-RestX - provided by AppSeed

blog-sample-flask-charts's People

Contributors

app-generator avatar swapniljariwala avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.