Web Server - PFE-TrieuseConsigne/RPi GitHub Wiki
In order to enable the web server, type the following commands
sudo apt-get install apache2
sudo apt-get install libapache2-mod-wsgi
sudo a2enmod wsgi
sudo apt-get install mariadb-client
sudo apt-get install mariadb-server
cd /var/www/
We want 2 instance of FlaskApp
sudo mkdir FlaskApp
cd FlaskApp
sudo mkdir FlaskApp
cd FlaskApp
Create a directory with public informations. People can access to those file by typing 10.0.0.199:8000/static
sudo mkdir static
Create a directory to store private data
sudo mkdir templates
Create a file with the main website informations
sudo nano -c -l __init__.py
sudo apt-get install python-pip
sudo apt-get install python3-pip
sudo pip install virtualenv
WARNING, we should be on the correct directory for the next command, which is /var/www/FlaskApp/FlaskApp/
sudo virtualenv venv
Go into the virtual environment
First of all, make sure you are in the directory with the virtual environment is installed and then, type the following command. For the exemple here, you should be on the /var/www/FlaskApp/FlaskApp/
source venv/bin/activate
After that, you should see that your root changed for
(venv) pi@raspberrypi:
Once in the virtual environment, we want to install Flask like so
sudo pip install Flask
To get out of the virtual environment, type the following command
desactivate
Configure apache server
sudo nano /etc/apache2/sites-available/FlaskApp.conf
To activate those configurations, type the following commands
sudo a2ensite FlaskApp
systemctl apache2 reload
cd /var/www/FlaskApp
sudo nano flaskapp.wsgi
In this file, the secret key is setup
service apache2 restart
sudo pip install numpy
sudo python3 -m pip install opencv-python