Skip to content

MarcelFox/flask_base

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

78 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Flask_Base:

It's a MVT structure to start developing web applications based on Flask. The structure is improved to work with PostgreSQL, but you can also work with any other RDBMS. There's also a simple Blackjack game made with jQuery's ajax functionality to provide an example of how to communicate with the server's routes, just for fun.


Git Clone and Deploy:

To start working with it you must clone this repository and provide a optimal virtualenvironment in order to deploy Flask_Base. It's important to install virtualenvwrapper on your system, it's a great tool to manage virtualenv.

Your system must have Postgresql installed, and the following packages will be required:


postgresql-11 libpq-dev python3-dev


Remember:

You must configure a user and a database for your application on PostgreSQL!



After you've installed those system dependencies, you can proceed cloning Flask_Base:


  

# git clone http://github.com/MarcelFox/flask_base

  

# cd flask_base/

  

# mkvirtualenv --python="/usr/bin/python3" -r requirements.txt venv_name

  


This flask base structure uses environment variables which works very well with virtualenvwrapper. At this point we have to set up only two variables:

SECRET_KEY

DATABASE_URL


Just add the following lines into the postactivate file on your virtualenv:

$HOME/.virtualenvs/venv_name/bin/postactivate:


  

export FLASK_APP='$HOME/flask_base/run.py'

  

export SECRET_KEY='Shrubbery'

  

export DATABASE_URL='postgresql://USER:PASS@localhost/DATABASE'

  


You also need to unset these variables when you deactivate from your virtualenv:

$HOME/.virtualenvs/venv_name/bin/postdeactivate:


  

unset FLASK_APP

  

unset SECRET_KEY

  

unset DATABASE_URL

  


Run!


(venv)$ uwsgi --ini="uwsgi.ini"

Now your application will be accessible on:

http://localhost:8080/

About

A base pattern to start Flask applications.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published