flask-server/README.md

53 lines
1.7 KiB
Markdown
Raw Normal View History

2024-10-08 13:20:00 -04:00
# Things you'll have to do once to initialize the project
Do the following in order:
## Create an .env file
```(bash)
cp env.example .env
```
Then edit the .env file to enter a flask secret key, your omdb key and an administrator password for the site.
## Initialize the environment
There is a configure.sh file:
```(bash)
sh configure.sh
```
You can also initialize the environment yourself:
### Create a virtual environment
Create an `env` folder:
```(bash)
python -m venv env
```
To enter the `(env)` environment:
```(bash)
source env/bin/activate
```
The keyword `(env)` should appear in the beginning of the prompt. If you want to quit the virtual environment, do `deactivate`.
If you are not in the virtual environment (the `(env)` keyword does not appear in the prompt), do `source env/bin/activate` again to go back to the environment.
### Install the required python packages
```(bash)
python -m pip install -r requirements.txt
```
### Initialize the database
Warning! This will erase the database.
Pro-tip: this will erase the database.
```(bash)
python -m flask --app kinolist init-db
```
# Things to do whenever you want to launch the project locally
## Enter the local environment
```(bash)
source env/bin/activate
```
The keyword `(env)` should appear in the beginning of the prompt. If you want to quit the virtual environment, do `deactivate`.
If you are not in the virtual environment (the `(env)` keyword does not appear in the prompt), do `source env/bin/activate` again to go back to the environment.
## Launch the Flask server
```(bash)
python -m flask --app kinolist run --port 8000 --debug
```
You can access the site at the adress `localhost:8000` on your web browser. Do `Ctrl+C` to stop the server.