Skip to content

Windows Setup

Timothy Ko edited this page May 20, 2018 · 2 revisions

Setup for Windows Subsystem for Linux

Some prerequisites:

  • Python 3
  • pip 9.0 (this should come with your Python 3 installation)

Clone the repository and cd into it:

$ git clone https://github.com/tko22/flask-boilerplate.git
$ cd flask-boilerplate

Download and install PostgreSQL 10 from here. Leave the default settings checked, and you don't need to install any of the additional components. Remember the password you set for your postgres user account.

In your shell, install the necessary packages:

$ sudo apt-get update
$ sudo apt-get install postgresql-client-common postgresql-client

Verify that your Postgres installation worked:

$ psql -p 5432 -h localhost -U postgres

You should see the Postgres shell after the above command, and it should look like this:

postgres=#

Create a user 'testusr' with password 'password', and a database 'testdb'. Then, grant privileges to the newly created user:

postgres=# CREATE USER testusr WITH PASSWORD 'password';
postgres=# CREATE DATABASE testdb WITH OWNER testusr ENCODING 'utf-8';
postgres=# GRANT ALL PRIVILEGES ON DATABASE testdb TO testusr;

To quit out of the Postgres CLI:

postgres=# \q

Let's install pipenv, our virtual environment and package manager.

$ pip install pipenv

Now, you install from the Pipfile, which describes the list of dependencies.

$ pipenv install

Next, activate the python virtual environment and you should see something like (flask-boilerplate-_rcP-Rlt) appear before your commands to indicate that you are in your virtual environment:

$ pipenv shell

Run the server with your virtual environment still activated:

(flask-boilerplate-_rcP-Rlt)$ python manage.py runserver

Visit the API at http://127.0.0.1:5000/ to bask in the glory of your hard work.

To deactivate your virtual environment, just do:

(flask-boilerplate-_rcP-Rlt) $ deactivate

You may also run the command outside of the virtual environment with pipenv run before the command:

$ pipenv run python manage.py runserver