Skip to content

Latest commit

 

History

History
60 lines (44 loc) · 1.78 KB

README.md

File metadata and controls

60 lines (44 loc) · 1.78 KB

Python with Flask

🔧 Pre-requisites

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-flask

🚀 Project setup

> Setting the environment variables

Create 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_name

You can also change the API_KEY variable value, but if you leave the default value, the project will still work properly.

> Running the app

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 run

Open http://127.0.0.1:5000 to view it in the browser.

> Creating the database

First, you'll need to open up a Python interactive shell:

flask shell

The 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()