Before running the project, you must have the following tool installed on your machine:
Also, you will need to clone the repository:
## Cloning the repository
git clone https://github.com/mateuseap/python-with-flask
## Entering the directory
cd python-with-flaskCreate a file named .env and copy and past in it what is inside the .env.example file (create the .env file in the same place that .env.example file is localized). After that, you'll need to change de DATABASE_URL variable value and put in it the URL of your own database, following the given structure:
## Database URL
postgresql://username:password@host:port/database_nameYou can also change the API_KEY variable value, but if you leave the default value, the project will still work properly.
You'll need to run the commands below:
## Creating a virtual environment
python -m venv env
.\env\Scripts\activate
## Upgrading the pip
python -m pip install --upgrade pip
## Installing dependencies
pip install -r .\requirements.txt
## Running the app
python -m flask runOpen http://127.0.0.1:5000 to view it in the browser.
First, you'll need to open up a Python interactive shell:
flask shellThe special shell above runs commands in the context of the Flask application, so that the Flask-SQLAlchemy functions called are connected to the application. After openning this shell, you'll just need write this in it to create the database:
from app import db, User
db.create_all()
exit()