# Week2

## DB Webserver Connection

* create user for remote access:

![](<../assets/92898586767705871114.png>)

* allow connections through firewall: `sudo ufw allow from 0.0.0.0 to 0.0.0.0 port 3306 proto tcp`
* get python dependencies: `sudo apt update && sudo apt install python3 python3-pip python3-venv`
* `cd /home/champuser/proj/`
* create virtual environment: `python3 -m venv .venv` activate: `. .venv/bin/activate`

install flask: `pip install flask`

Create directory for Flask: `mkdir Flask, cd Flask`

dependencies `pip install Flask-MySQLdb pip install flask-mysql pip install cryptography`

![](<../assets/03636611901023297692.png>)

![](<../assets/72766234477222890914.png>)

![](<../assets/19930188638651808078.png>)

![](<../assets/33901315023577898721.png>)

if localhost doesn't work, change bind-address in /etc/mysql/mysql.conf.d/mysqld.cnf

## Filter from application

* add form action&#x20;
![](../assets/formaction.png)

* add python form processing

&#x20;![](<../assets/62052853300074043448.png>)

## for pets db

![](<../assets/53438651249532045143.png>)
