# pollenviz The purpose of the application is store and visualise pollen data. ## PLEASE NOTE This branch (master) is under development and will frequently change. Please use the v1.0 tag to install pollenviz. ## Features * Simple data import with csv files via gui or api * GUI for editing data * View and compare data ## Requirements The following is required to install and run the application: * Postgres 9.5+ (https://www.postgresql.org/download/) * Postgis extension (https://postgis.net/install/) * Python 3 (https://www.python.org/downloads/) * Yarn/NPM * WSGI complient server * See requirements.txt for external python libraries used ## Configuration Add a file in the web folder called config.ini. Look at config.example.ini to see what needs to be inside. ## Database Setup postgres database with the postgis extension. Import the schema.sql file from the db_scripts folder. ## Running the app Install all required python libraries with: ```powershell pip install -r requirements.txt ``` Navigate to the web/client folder and build the gui with the command: ```powershell yarn install yarn build ``` Run the python server with the the following command: **Linux** ```powershell export FLASK_APP=web flask run ``` **Windows** ```powershell $env:FLASK_APP = "web" flask run ``` See https://flask.palletsprojects.com/en/1.1.x/quickstart/ for more information. ## Development Make sure you have all javascript packages installed by running `yarn` in the web/client folder. Run `yarn build` once so the python server has the required files. Start the web server as described in "running the app" Start the client side server by running the command `yarn serve` ## Linux web server On the webserver we have to start with a configuration for apache2. Write a custom configuration file, /etc/apache2/sites-available/pollenviz.conf. The ServerName settings in pollenviz.conf has to be registered as a CNAME, pointing to the A-record for the webserver, in the DNS-servers. Make ssl-certs for https://someurl.com, and put the key and crt file into /etc/apache2/ssl. Make a DocumentRoot directory under /var/www/html, call it pollenviz. Give it sufficient permissions for apache2 to be able to read it. Copy all of the files in the web folder to there. Make a pollenviz.wsgi file, to start the application. Here we source the virtual environment and starts the application. Next is to make a virtual environment for python, and then installing all the modules from requirement.txt from that. psycopg2 is dependent on libpq-dev and python-dev. ## IIS Please follow this article to install the application on IIS: http://netdot.co/2015/03/09/flask-on-iis/ Make sure the Python folder has IIS_IUSRS rights. Install all dependencies from requirements.txt globally or with virtualenv. To do this globally run the following line in the python script folder: ```pip install -r requirements.txt``` It is highly recommended that you set up your server with **https** ## Importing data Importing data is done by uploading sensors and observations as csv files. See csv_examples. Use [Curl](https://curl.haxx.se/), [Postman](https://chrome.google.com/webstore/detail/postman/fhbjgbiflinjbdggehcddcbncdddomop) or similar tools for this. Set Content-Type to "multipart/form-data" and use the form name "csv". Example uploading networks with curl ``` curl -X POST -u usr:psw --form "csv=@path/to/sensors.csv" https://someurl.com/imports/sensors ``` If you upload a content with id's that exists, it will be updated. There are dependencies between the csv files, so the import order is important. Start with sensors and observations ### Security This application uses basic authentication. The default user:password combination is admin:admin It is recommended to change the default password immediately. You can do this with the user management module on pollenviz web site.