Skip to content

Data based Python, bootstrap styled flask template website

License

Notifications You must be signed in to change notification settings

martinprobson/DataWeb_Template

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

DataWeb Template

Introduction

This is a python, bootstrap styled flask template website.

It is a basic template layout designed to show how data issues and measures can be presented to the user in various forms (tabular/text/chart).

Flask-User and Flask-Login modules are used to provide user validation.

SQLAlchemy with the corresponding flask plugin provides the db access layer.

bokeh and pygal provide sample charts.

bootstrap-table provides enhanced data table support.

Markdown support uses the technique shown here

Email user registration is supported, but first a valid SMTP server needs to be setup in config.py: -

#
# Flask-Mail SMTP settings - These are used by Flask-User to send user email verification emails
#
MAIL_USERNAME       =     os.getenv('MAIL_USERNAME',        'dummy@somewhere')
MAIL_PASSWORD       =     os.getenv('MAIL_PASSWORD',        '<password>')
MAIL_DEFAULT_SENDER =     os.getenv('MAIL_DEFAULT_SENDER',  '<sender>')
MAIL_SERVER         =     os.getenv('MAIL_SERVER',          'smtp server')
MAIL_PORT           =     int(os.getenv('MAIL_PORT',         '587'))
MAIL_USE_TLS        =     int(os.getenv('MAIL_USE_TLS',      True))
MAIL_USE_SSL        =     int(os.getenv('MAIL_USE_SSL',      False))

# Make sure SMTP setting are set correctly above before setting this to False....
USER_ENABLE_LOGIN_WITHOUT_CONFIRM_EMAIL=True

and USER_ENABLE_LOGIN_WITHOUT_CONFIRM_EMAIL should be set to False. See this page for user/security configuration options.

Bootstrap theming is supported via the user profile page.

Setup

The project is designed to be run in an Anaconda virtualenv using the procedure described here

  1. Clone project from git.
  2. Create a conda virtualenv using conda env create (this uses the environment.yml file to install all required packages in virtualenv).
  3. Activate the virtualenv with source activate DataWeb (DataWeb is the name of the environment as specified in the environment.yml file).
  4. If autoenv is installed, then a .env file can be created in project root, this will automatically activate the virtualenv on cd and sets up a couple of env vars needed by flask cli: -
	source activate DataWeb
	export FLASK_APP=DataWeb
	export FLASK_DEBUG=true
  1. The project is structured as a Python setuptools package. The project structure follows the pattern as described in the flask docs.

Running for the first time

  1. Use pip to install the app locally - in the project directory. From DataWeb_Template/DataWeb directory run : -
	pip install -e . 
	flask run
  1. To run the code for the first time, you first need to initialize the sqllite db that contains sample issues and user information. To do this use: -
flask initdb

This also loads some dummy issues in the issue table and a test user test with password set to Test1234 - see LOAD_DUMMY_DATA setting in config.py.

Starting the webserver

To start the webserver use: -

  • python run.py or flask run (from the DataWeb/DataWeb directory)

Adding/Removing Menu Items

To add or remove pages from the dropdown menus, change the html in base.html: -

              <ul class="dropdown-menu">
                <li class="dropdown-header">Sample Pages</li>
                <li><a href="{{ url_for('show_pygal_chart') }}">Sample Chart (pygal)</a></li>
                <li><a href="{{ url_for('show_bokeh_chart') }}">Sample Chart (bokeh)</a></li>
                <li><a href="{{ url_for('show_markdown') }}">Sample Markdown text</a></li>
                <li><a href="{{ url_for('enhanced_table') }}">Enhanced Table Output</a></li>
                <li><a href="{{ url_for('wait') }}">Wait Example</a></li>
                <li role="separator" class="divider"></li>

Martin Robson - 2017

About

Data based Python, bootstrap styled flask template website

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published