Giter Site home page Giter Site logo

python-flask-todo's Introduction

PYTHON FLASK TODO APP - MYSQL

This is a traditional Python 3 TODO app with Flask framework. This project is based on Patrick Loeber's video analysing three Python frameworks for Web apps.

This branch replaces SQLLite with MySQL DB.

If you want to understand the underlying application, please check out the main branch.

Overview

There are two main differences between this and the main branch. First, we add PyMySQL to the requirements.txt file. PyMySQL is a MySQL client for Python.

Second, we changed application.py to consider MySQL URL and retrieve necessary data from environment variables, like so:

(...)

import os

(...)

app.config['SQLALCHEMY_DATABASE_URI'] = "mysql+pymysql://{}:{}@{}/{}".format(
	os.getenv("RDS_USERNAME"),
	os.getenv("RDS_PASSWORD"),
	os.getenv("RDS_HOSTNAME"),
	os.getenv("RDS_DB_NAME"),
)

(...)

Running the Project Locally

  1. Clone the project locally
git clone https://github.com/gabrielcostasilva/python-flask-todo.git
  1. In the project folder, create and activate a virtual environment
python3 -m venv venv
source venv/bin/activate

  1. Install dependencies
pip install -r requiments.txt
  1. Create four environment variables with required data for accessing the MySQL DB as follows
export RDS_USERNAME=USERNAME-TO-ACCESS-DB
export RDS_PASSWORD=PASSWD-TO-ACCESS-DB
export RDS_HOSTNAME=LOCALHOST
export RDS_DB_NAME=DB-NAME
  1. Start the application
python3 application.py
  1. Access the app with your browser at http://localhost:5000

Running the Project on AWS Elastic Beanstalk

First, ensure you have AWS CLI and EB CLI installed and configured.

  1. Clone the project locally
git clone https://github.com/gabrielcostasilva/python-flask-todo.git
  1. In the project folder, initilize the application
eb init \
    -r us-east-1 \
    -p python-3.8
  1. Create your Beanstalk environment
eb create -s -db.engine mysql
  1. When the environment is ready, access the app
eb open
  1. Terminate your environment
eb terminate

Note that you can use a MySQL client (e.g. Workbench) to access your database on AWS RDS using the connection URL presented on your console during the environment creation.

python-flask-todo's People

Contributors

gabrielcostasilva avatar

Forkers

sujatha-renga

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.