IsiomaOgbuehi / wafi

wafi_test

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

tech stack will include the following:

  • virtualenv as a tool to create isolated Python environments
  • SQLAlchemy ORM to be our ORM library of choice
  • PostgreSQL optional. App already uses a local db
  • Python3 and Flask as our server language and server framework
  • Flask-Migrate for creating and running schema migrations You can download and install the dependencies mentioned above using pip as:
pip install virtualenv
pip install SQLAlchemy
pip install Flask
pip install Flask-Migrate

Main Files: Project Structure

├── README.md
├── app.py *** the main driver of the app. Includes your SQLAlchemy models.
                  "python app.py" to run after installing dependences
├── config.py *** Database URLs, CSRF generation, etc
├── requirements.txt *** The dependencies we need to install with "pip3 install -r requirements.txt"
├── static
│   ├── css
└── templates
    ├── layouts
    └── pages
 ├── app.db *** Local DB - testing purpose 

Overall:

  • Models are located in the MODELS section of app.py.
  • Controllers are also located in app.py.
  • The web frontend is located in templates/, which builds static assets deployed to the web server at static/.

Highlight folders:

  • templates/pages -- Defines the pages that are rendered to the site. These templates render views based on data passed into the template’s view, in the controllers defined in app.py.
  • templates/layouts -- Defines the layout that a page can be contained in to define footer and header code for a given page.
  • app.py -- Defines routes that match the user’s URL, and controllers which handle data and renders views to the user. This is the main app file that connects and manipulates the database and renders views with data to the user, based on the URL.
  • Models in app.py -- Defines the data models that set up the database tables.
  • config.py -- Stores configuration variables and instructions, separate from the main application code. This is where you will need to connect to the database if you want to connect to a DB like Postgres. However, the App already works with a local DB

Development Setup

  1. Initialize and activate a virtualenv using:
python -m virtualenv env
source env/bin/activate

Note - In Windows, the env does not have a bin directory. Therefore, you'd use the analogous command shown below:

source env/Scripts/activate
  1. Install the dependencies:
pip install -r requirements.txt
  1. Run the development server:
export FLASK_APP=app.py
export FLASK_ENV=development # enables debug mode
flask run
  1. Verify on the Browser
    Navigate to project homepage http://127.0.0.1:5000/ or http://localhost:5000

About

wafi_test


Languages

Language:Python 70.3%Language:HTML 22.7%Language:CSS 5.7%Language:Mako 1.3%