Server and front-end for project DB Team 3
We use a Flask server
-
Setting up the environment (same as tutorial)
- cd Flask_server
- virtualenv -p python3 env (only fist time)
- source env/bin/activate
- pip3 install -r requirements.txt (only fist time)
-
Start the test server -cd src/ProgDBTutor/ -python app.py
- open Flask_server\src\ProgDBTutor in Pycharm
- App.py contains all api url's like "/api/helloWorld" when you http://localhost:5000/api/helloWorld you will get Hello world because the function helloWorld() returns the string "Hello world" we will use this the return json information
- the folder "react_build" contains the builded version of the react front end, all url's that are not app.route() will redirect to this folder
We use react !!! Don't upload node_modules to github !!!
- open "React_front_end" in terminal
- Run in the terminal npm install
Can be used to design the front end
- open "React_front_end" in Webstorm
- Run in the terminal npm start
the build will automatically copy itself to the flask server in the folder "react_build"
- run following command in the "React_front_end" folder: npm run build
- Test if react is corectly build with the python flask server
src/ProgDBTutor/app.py
change port and redirections
src/pages
style for different pages
config_data = dict()
config_data['app_name'] = 'appname' (ProgDB Tutor)
config_data['dbname'] = 'dbname' (dbtutor)
config_data['dbuser'] = 'user' (app)
config_data['uri'] = 'postgresql://username:password@localhost:5432/dbname'
create user postgrespython with encrypted password 'dbAdmin';
CREATE DATABASE avsaDB OWNER postgresPython;
add > data source > postgreSQL >
gegevens:
name = avsadb
host = localhost
user = postgrespython
password = dbAdmin
database = avsadb
port = 5433 or default
-> test connection
right click public > Run SQL script... > Select schemaInitialization.sql
ga naar de app user:
sudo su app
git pull:
git pull
ga naar eigen user:
exit
to start te gunicorn server: gunicorn --bind 0.0.0.0:8000 -k eventlet -w 1 wsgi:app
Restart webapp:
sudo systemctl restart webapp