Coder Social home page Coder Social logo

fabriziomiano / covidashit Goto Github PK

View Code? Open in Web Editor NEW
9.0 3.0 2.0 37.08 MB

COVID-19 Italy Pandemic and Vaccines Dashboard

Home Page: http://covidash.it

License: MIT License

Python 47.01% JavaScript 11.16% HTML 38.47% CSS 2.81% Shell 0.16% Batchfile 0.14% Dockerfile 0.26%
python flask-app covid19-tracker covid-italia covid19-italy highcharts docker dashboard bootstrap javascript

covidashit's Introduction

COVID-19 Italy Monitor | #StayAtHome

Awesome Open Source Love Made with Pthon

alt_text

A simple dashboard to display and monitor the official data of the COVID-19 outbreak in Italy, released by the Italian Civil Protection Dept., and the vaccination-status data, released by Italia Open Data.

The app is deployed on an AWS EC2 instance here

Pandemic data from the official CP Dept repository

Vaccine data from the official open-data repository

For developers

The WebApp requires Python 3.10 and reads the data from a mongoDB. It employs a Flask server with gunicorn in front of it. Furthermore, it employs Flask-babel for the italian translation, as English is set as primary language. The script make_pot.sh creates the files needed by Babel for the translations. A Batch version of the script for Windows users is provided. The app language is decided upon the client request (browser / OS).

The front-end lives under covidashit/templates and it uses JS to create the chart object, which is built using HighCharts.

In order for the app to be operational, a mongoDB must be populated (see here for the creation of an Atlas mongoDB free cluster). The backend is populated by covidashflow - an Apache-Airflow ETL - which reads the pandemic data from the master branch of the PCM-DPC repository, and the vaccines data from the master branch of the Italia Open Data repository

Local deployment (DEV)

  • create and activate a virtual environment (follow this)
  • install the requirements via poetry pip install --upgrade pip poetry && poetry install

The .env file contains all the env vars needed by the webapp. In particular, the MONGO_URI and the various collection names string must be set. The values of these variables should match those in covidashflow The WebApp should start without errors even if the backend is empty; no data will be visualized.

Clone the repo, cd into it, activate the virtual environment, run the application server

gunicorn wsgi:app

Docker

To test the containerization locally spawn the container with:

docker-compose up -d

The docker container will be listening at http://127.0.0.1:PORT with PORT being set in the .env file

Stop it with

docker-compose down

Plots API

The app provides an API to produce plots with matplotlib. The API can return a JSON response with the base64-encoded image, or the bytes content to be saved as a file.

Resource URL

https://www.covidash.it/api/plot

Query parameters

data_type var_name area
national [nuovi_positivi, ingressi_terapia_intensiva, deceduti_g, tamponi_g,totale_ospedalizzati_g, nuovi_positivi_ma, deceduti_g_ma, ingressi_terapia_intensiva_ma, tamponi_g_ma, totale_ospedalizzati_g_ma, totale_positivi, terapia_intensiva, ricoverati_con_sintomi, totale_ospedalizzati, isolamento_domiciliare, totale_casi, deceduti, tamponi, dimessi_guariti] N/A
regional [nuovi_positivi, ingressi_terapia_intensiva, deceduti_g, tamponi_g,totale_ospedalizzati_g, nuovi_positivi_ma, deceduti_g_ma, ingressi_terapia_intensiva_ma, tamponi_g_ma, totale_ospedalizzati_g_ma, totale_positivi, terapia_intensiva, ricoverati_con_sintomi, totale_ospedalizzati, isolamento_domiciliare, totale_casi, deceduti, tamponi, dimessi_guariti] [Abruzzo, Basilicata, Calabria, Campania, Emilia-Romagna, Friuli Venezia Giulia, Lazio, Liguria, Lombardia, Marche, Molise, Piemonte, Puglia, Sardegna, Sicilia, Toscana, P.A. Bolzano, P.A. Trento, Umbria, Valle d'Aosta, Veneto]
provincial [nuovi_positivi, nuovi_positivi_ma, totale_casi] [Chieti, L'Aquila, Pescara, Teramo, Matera, Potenza, Catanzaro, Cosenza, Crotone, Reggio di Calabria, Vibo Valentia, Avellino, Benevento, Caserta, Napoli, Salerno, Bologna, Ferrara, Forlì-Cesena, Modena, Parma, Piacenza, Ravenna, Reggio nell'Emilia, Rimini, Gorizia, Pordenone, Trieste, Udine, Frosinone, Latina, Rieti, Roma, Viterbo, Genova, Imperia, La Spezia, Savona, Bergamo, Brescia, Como, Cremona, Lecco, Lodi, Mantova, Milano, Monza e della Brianza, Pavia, Sondrio, Varese, Ancona, Ascoli Piceno, Fermo, Macerata, Pesaro e Urbino, Campobasso, Isernia, Alessandria, Asti, Biella, Cuneo, Novara, Torino, Verbano-Cusio-Ossola, Vercelli, Bari, Barletta-Andria-Trani, Brindisi, Lecce, Foggia, Taranto, Cagliari, Nuoro, Sassari, Sud Sardegna, Agrigento, Caltanissetta, Catania, Enna, Messina, Palermo, Ragusa, Siracusa, Trapani, Arezzo, Firenze, Grosseto, Livorno, Lucca, Massa Carrara, Pisa, Pistoia, Prato, Siena, Perugia, Terni, Aosta, Belluno, Padova, Rovigo, Treviso, Venezia, Verona, Vicenza]

Examples

National plot

GET /api/plot?data_type=national&varname=<varname>

Regional plot

GET /api/plot?data_type=regional&area=<region>&varname=<varname>

Provincial plot

GET /api/plot?data_type=provincial&area=<province>&varname=[nuovi_positivi,nuovi_positivi_ma,totale_casi]>

To get the base64-encoded image in a JSON response

JSON

Request

curl --request GET \ 
     --url 'https://www.covidash.it/api/plot?data_type=national&varname=totale_casi'

Response

{
    "errors":[],
    "img":"iVBORw0KGgoAA...",
    "status":"ok"
}

To download the file

Request

curl --request GET \
     --url 'https://www.covidash.it/api/plot?data_type=national&varname=totale_casi&download=true' \
     --output plot.png

The plot will be saved in ./plot.png

Plot preview

alt_text

Donation

If you liked this project or if I saved you some time, feel free to buy me a beer. Cheers!

paypal

covidashit's People

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

covidashit's Issues

People resurrected

Yesterday have been a very good day, ad 571 people resurrected... :-D
Today a little worse...

image

Errore Pie chart "Somministrazioni per fornitore"

Vorrei evidenziare un problema che si è verificato sicuramente da quanto il vaccino Astrazeneca ha cambiato nome, in particolare nei pie chart relativi alle somministrazioni per fornitore.
Il numero di dosi somministrate di Vaxzevria (AstraZeneca) comprende già il numero di dosi somministrate in precedenza con AstraZeneca, infatti se si fa la somma di dosi somministrate con Pfizer/BioNTech, Moderna e Vaxzevria (AstraZeneca) si ottiene il numero totale delle somministrazioni. Se aggiungessimo anche quelle dello spicchio identificate solamente con AstraZeneca, si supererebbe il totale.

Sperando di averLe fatto cosa gradita,
un cordiale saluto

New people categories

Add the new categories to the vaccine dashboard

  • Personale Scolastico
  • Forze Armate
  • Altro

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.