Giter VIP home page Giter VIP logo

flask-template's Introduction

Setting up the development environment

Prerequisites Python3 and Pip (install guide), virtualenv (install guide), and git (another install guide).

  1. Clone the repository

  2. Navigate to the repository's top level (the level with README.md, requirements.txt, the folder app, etc)

  3. Create a virtual environment with python 3 and enter it (guide here)

  4. Install the required python packages from requirements.txt (guide here)

  5. Create a copy of config-example.py in the same directory called config.py and fill it in with your secrets. config.py already has an entry in .gitignore

  6. Set the Flask environment variables

Unix:

export FLASK_ENV=development
export FLASK_APP=myapp

Windows CMD:

set FLASK_ENV=development
set FLASK_APP=myapp

Windows PowerShell:

$env:FLASK_ENV='development'
$env:FLASK_APP='myapp.py'
  1. Run it!
flask run

Tips & Tricks & Notes

How do I run code on application startup?

Put it in /app/init.py

How do I run this under Apache?

  1. Install Apache

  2. Install the appropriate version of mod_wsgi for your distribution and version of Python.

  3. Download this project and set it up based on the instructions in the previous section, Setting up the development environment

  4. Add an Apache virtual host with the following details

WSGIDaemonProcess fugue python-home=[PATH_TO_VIRTUALENV] home=[PATH_TO_PROJECT_HOME]
WSGIApplicationGroup %{GLOBAL}
WSGIScriptAlias /[PATH] [PATH_TO_CONF_WSGI]
<Directory [PATH_TO_PROJECT_HOME]>
    WSGIProcessGroup [PROCESS_GROUP_NAME]
    Options FollowSymLinks
    AllowOverride None
    Require all granted
</Directory>

Example variable values are as follows:

  • PATH_TO_VIRTUALENV: "/home/djbeadle/flask-template/venv/"
  • PATH_TO_PROJECT_HOME: "/home/djbeadle/flask-template"
  • PATH: "flask_template"
  • PATH_TO_CONF_WSGI: "/home/djbeadle/Daniel-fugue-take-home/conf.wsgi"
  • PROCESS_GROUP_NAME: "flask_template"
  1. Restart Apache and see if it works!

  2. Tweak your project's home directory permissions if Apache can't access it.

Build and Test

Tests can be run from the root directory with the command

pytest

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.