This time, as the title says, I will make a simple book management application using python and Flask.
I'm currently studying programming at university, but I've only made programs and reports that I was told to "make and submit" in a lecture. I have almost never created an app or program by thinking from scratch.
So, this time I'm going to make a web application from scratch for the first time. I create it while referring to various sites, but I think there are probably various ways to write a program that is more suitable than the one I created. So, at that time, you can point it out.
I'm thinking of posting what I didn't understand or stumbled upon when making this web app, so if you want to make a book management app like me easily, please refer to it. I would appreciate it if you could.
Then, I will actually make it.
This time, I will make a web application that manages books. We will continue to create web applications while proceeding with the following assumptions, so thank you.
Also, since I updated to Catalina, I am executing commands with zsh instead of bash.
So the `$ mark is now the% mark`
.
In the execution result,% is displayed as \ $ when the command is executed, but I think it's okay if you don't mind.
It may be incorrect information, so if it is incorrect, please correct it.
MacBook Air / macOS Catalina version 10.15.1 python 3.7.4 Flask 1.1.1 mysql Ver 8.0.18 for osx10.15 on x86_64 (Homebrew) mysqlclient 1.4.6
First of all, we will introduce the database and library written on the premise. I will proceed with the introduction of python assuming that it has already been introduced this time. Also, since this is an introductory edition, we will do the following parts.
Move to the directory you want to work in in the order of the following commands, build a virtual environment, and activate to work.
terminal
$ cd {Working directory path}
$ python3 -m venv {Virtual environment name}
$ . {Virtual environment name}/bin/activate
I did the following:
terminal
$ cd ~/Desktop/work
$ python3 -m venv venv
$ . venv/bin/activate
Here, if you execute pip3 list
to check the library, you will see the following execution result. (Because my real name is in [name]. I'm lying down.)
If necessary, run `` `pip3 install --upgrade pip```.
terminal
({Virtual environment name}) [name]@Hello-World {Working directory name} % pip3 list
Package Version
---------- -------
pip 19.3.1
setuptools 39.0.1
({Virtual environment name}) [name]@Hello-World {Working directory name} %
In my case, the virtual environment name is venv and the working directory name is work, so it looks like the following. After that, it will be executed in various ways in the following virtual environment, so if you have changed each name, please read it as appropriate.
terminal
(venv) [name]@Hello-World work % pip3 list
Package Version
---------- -------
pip 19.3.1
setuptools 39.0.1
(venv) [name]@Hello-World work %
We will install the necessary libraries from here. Execute the following command.
terminal
$ pip3 install flask
$ pip3 install request
$ pip3 install mysqlclient
And if you run pip3 list
again, you should see something like the following.
This completes the installation of the library.
terminal
[name]@Hello-World ~ % cd Desktop/work
[name]@Hello-World work % . venv/bin/activate
(venv) [name]@Hello-World work % pip3 list
Package Version
------------ ---------
Click 7.0
Flask 1.1.1
get 2019.4.13
itsdangerous 1.1.0
Jinja2 2.10.3
MarkupSafe 1.1.1
mysqlclient 1.4.6
pip 19.3.1
post 2019.4.13
public 2019.4.13
query-string 2019.4.13
request 2019.4.13
setuptools 40.8.0
Werkzeug 0.16.0
(venv) [name]@Hello-World work %
Finally, we will introduce the MySQL used this time using Homebrew. If you have homebrew, please run only the second one.
terminal
$ /usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
$ brew install mysql
This time, the introduction is biased, so this is the end. Next time, I will actually create a program. Thank you for watching.
Recommended Posts