Skip to content

Instantly share code, notes, and snippets.

@benschac
Last active November 17, 2018 16:32
Show Gist options
  • Save benschac/9d741dded4a3a1adf3e91baff12b57af to your computer and use it in GitHub Desktop.
Save benschac/9d741dded4a3a1adf3e91baff12b57af to your computer and use it in GitHub Desktop.

FIRST, get the following set up:

These should be the full commands to install (assuming you're using bash and not ZSH):

pyenv
brew install pyenv
mkdir -p ~/.pyenv && pyenv init - > ~/.pyenv/pyenv.sh
echo "source ~/.pyenv/pyenv.sh" >> ~/.bash_profile && source ~/.bash_profile
pyenv install 3.7.1
pyenv global 3.7.1

If you get an install error on 3.7.1, I have the fix.

pipenv brew install pipenv echo "export PIPENV_VENV_IN_PROJECT=1" >> ~/.bash_profile

autodocstring code --install-extensions njpwerner.autodocstring

Once that's done, create a git repo with the standard Python ignore and run these commands inside the repo directory: pipenv install flask requests pipenv install --dev flake8 yapf pylint pytest

And add this to .vscode/settings.json in the repo directory

{
  "editor.formatOnSave": true,
  "python.formatting.provider": "yapf",
  "python.formatting.yapfPath": "${workspaceFolder}/.venv/bin/yapf",
  "python.linting.enabled": true,
  "python.linting.flake8Enabled": true,
  "python.linting.flake8Path": "${workspaceFolder}/.venv/bin/flake8",
  "python.linting.pylintEnabled": true,
  "python.linting.pylintPath": "${workspaceFolder}/.venv/bin/pylint",
  "python.pythonPath": "${workspaceFolder}/.venv/bin/python"
}

Make a pylint.ini file in the repo directory with the following contents:

  • [pytest]
  • testpaths = tests

Make a file in tests/test_hello.py with the following contents:

"""Hello World Flask Test"""
import pytest

def test_that_true_is_true:
    assert true == true

And that should get you a bare-bones setup ready to make a flask app inside. LMK when you've done it and I'll send you next steps, which involves creating a controller and view templates and stuff, as well automated testing.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment