bunop / FLASKetude

Testing Python Flask

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

FLASK Etude

This repository is my personal interpretation of Flask Rest API - Zero to Yoda Series' Articles

Requisites

In order to install (and execute) this repository, you require:

Install

Start a MongoDB instance

Create an .env file in this project directory in which define those variables:

MONGODB_ROOT_USER=root
MONGODB_ROOT_PASS=<password>
MONGOEXPRESS_USER=flask
MONGOEXPRESS_PASS=<password>
APP_USER=flask
APP_PASS=<password>
JWT_SECRET_KEY=<secret key>
MAIL_SERVER=localhost
MAIL_PORT=1025
MAIL_USERNAME=support@movie-bag.com
MAIL_PASSWORD=

Next start MongoDB using docker-compose:

$ docker-compose up -d

In order to connect to your local MongoDB docker instance and create user:

$ docker-compose run --rm --user mongodb mongo sh -c 'mongo --host mongo --username="${MONGO_INITDB_ROOT_USERNAME}" --password="${MONGO_INITDB_ROOT_PASSWORD}"'

Create a user for movie-bag database with readWrite permissions:

use admin
db.createUser({user: "flask", pwd: "<password>", roles: [{role: "readWrite", db: "movie-bag"}]})
db.grantRolesToUser("flask", [{role: "readWrite", db: "movie-bag-test"}])

Install python requirements

You need to install required packages in a new conda environment:

$ conda env create -f environment.yml
$ conda activate FLASKetude
$ poetry install

Running

Start a test smptd service:

$ python -m smtpd -n -c DebuggingServer localhost:1025

Start the application with:

$ python app.py

About

Testing Python Flask


Languages

Language:Python 98.5%Language:HTML 1.5%