This repo runs our API for Coronacidades tools, such as FarolCovid. You can access the API here: http://datasource.coronacidades.org/help
Use it like:
http://datasource.coronacidades.org/br/cities/cases/full
br/cities/cases/full
: Full history data from Brasil.IO with notification rate and estimated active casesbr/cities/cnes
: Beds and ventilators data from DataSus/CNESbr/cities/farolcovid/main
: Data filtered & cities'indicatores for FarolCovid appbr/cities/rt
: Cities effective reproduction number (Rt) calculations by datebr/cities/simulacovid/main
: Data filtered to serve SimulaCovid appbr/states/farolcovid/main
: Data filtered & states' indicators for FarolCovid appbr/states/rt
: State effective reproduction number (Rt) calculations by datebr/states/safereopen/main
: States' security and economic priority index for reopening sectorsworld/owid/heatmap
: Our World in Data data to serve the heatmaps
.env
file in root folder with very secretive variables to run some data.
Run the code to load the files
make loader-build-run
If you want to make changes on the code, you should run the loader with make loader-shell
to open the docker image and be able to edit the files directly in your editor.
In a different tab, run the Flask server
make server-build-run
If you want to make changes on the code, you should run the loader with make server-shell
to open the docker image and be able to edit the files directly in your editor.
You should see something at localhost:7000/<endpoint>
, like http://localhost:7000/br/cities/cases/full
Check the column
date_last_refreshed
if you made any changes! ;)
- Add the endpoint configuration parameters to
endpoints.yaml
- endpoint: 'br/cities/cases/full' # endpoint route following [country]/[unit]/[content]
python_file: get_cases # .py that generates data in loader/endpoints/
update_frequency_minutes: 15 # how often it should be updated in minutes
- Write a .py file in loader/endpoints/ that generates the endpoint data. This file must be structured as get_{template}.py
Do not use print
to log stuff. You can use the logger in logger.py
.
It is faily simple to do it.
from logger import logger
logger.debug('Your message {variable}', variable=3)
You have several logging levels: debug, info, warning and error. To change the level
you can just call logger.<level>
, i.e., logger.info()
.
-
Usually,
debug
is used to minor behaviours and it is useful to debug code :). -
The
info
level is being used to keep track of the overall expected behaviour. -
If you use
logger.error
, the message will also be posted to our slack channel #simulacovid-logs
Read more at loguru.
- Set the env variable
IS_PROD=True
- Add secrets folder