This time around I built a simple CRUD application which was of course a TODO -application. I followed this amazing guide from youtube: https://www.youtube.com/watch?v=Z1RJmh_OqeA
Compared to last times I've used flask I also used virtualenv which makes the development process little bit more simple with the ability to use a virtual environment in where a developer can install all the dependancies instead of doing it globally.
Installing virtualenv requires pip3 which is a python package manager.
sudo apt-get install python3-pip
Virtual env can be installed with the command pip3 install virtualenv and you can create a new environment in your project folder with the command virtualenv env, where env is simply the name of the environment.
Finally you can activate it from the project root with command: source env/bin/activate.
The final product running on localhost port 5000 looks like this:
After this I needed to configure the apache2 and mod-wsgi to get it working with this project.
I actually managed to get this working before in the class, but now I ran into issues with getting the production version of this working.
I have included a lot of screenshots about this. I followed this guide http://terokarvinen.com/2020/deploy-python-flask-to-production/, I did this on my virtualbox installation of Xubuntu.
I had apache2 properly installed and configured here and I also had a 'mikkowsgi' -user with proper permissions.
Also as can be seen here all my permissions were definately in order.
Checking the error log actually revealed the source of the issue.
I didn't have my sqlalchemy dependency installed properly here.
I tried first installing it again with the command sudo pip3 install flask_sqlalchemy but It gave me the following error:
A great thing about this particular error is that it gave me the solution for it. I needed to run the pip3 install -command with the -H flag on the sudo command.
After this I ran the command curl -s localhost | grept title and it actually seemed to working. It returned the title of my webpage and checking localhost:80 returned me the proper webapplication.