Home Code GatorLF Part 1: Setting up a GitHub repo and virtualenv

GatorLF Part 1: Setting up a GitHub repo and virtualenv

by Sean Ziegler
Feature Image for Setting up a Github repo

Nearly everyday on any UF Facebook page you can expect to see a lost and found post. Students post keys, wallets, student IDs, laptops, and all kinds of other lost items.

Here’s an example:

Just one of fifty lost IDs posted everyday on UF Facebook groups.

After seeing these pop-up day after day, I thought I could develop a website where UF students can find these kinds of lost-and-found items easily (and I needed to develop something to prove to employers that even mechanical engineers can code).

GatorLostAndFound.com

This series will follow the development of a new website called GatorLostAndFound.com or GatorLF for short.

I’m going to develop the site using Python (specifically the Flask web development framework).

I want to make it clear that this series is not a tutorial on Python or Flask. Although I will be explaining as I develop the web application, I assume you have at least some familiarty with both Python and Flask.

I have a few target features in mind:

  • Sign-up with Facebook O-Auth to make life easy
  • Sort lost items by type, geographic area, date, and other filters
  • E-mail notifications to renew posts after 30 days without activity
  • Messaging or comments between users to communicate and arrange for the return of lost items

This is just a quick list of general preliminary features and will change over time.

Domain Name

Fortunately, the domain name was an easy choice. I always use NameCheap as my domain registrar and once again, it didn’t disappoint. I registered the domain name

GatorLostAndFound.com

for just $8.88 for the first year.

Setting up a GitHub repository

As with most of my programming/development projects, I’ll begin by creating a GitHub repository. I’m lazy so I created a blank repo with the GitHub web interface and initialized a blank readme.md file.

Here’s the repo: https://github.com/seanziegler/GatorLF

Let’s clone the repo to our local machine by running the following commands:

cd C:\Users\Sean Ziegler\Coding
git clone https://github.com/seanziegler/GatorLF.git

Awesome, our repo is ready to go.

Python, pip, venv

I will develop this using python 3.6 so I’ll check to ensure I have a current version of python installed.

python --version
> Python 3.6.4

Great, let’s update pip to the latest version. (This is a little more annoying than usual since I only have access to a Windows laptop, it’s much nicer in a UNIX environment)

python -m pip install --upgrade pip

Now we will install and create a virtual environment to make sure we only use the packages specifically needed in this project, not other junk installed on my machine.

virtualenv venv

Now let’s create a .gitignore file and add the virtualenv to it so it’s not housed on GitHub. For Windows I’ll just create the file with explorer, but Linux users could run:

touch .gitignore
nano .gitignore

I’ll add the venv folder and .pyc files.

venv/
*.pyc

Don’t forget to activate your venv.

Windows:

venv\Scripts\activate.bat

Linux:

source venv/bin/activate

Installing necessary packages

Okay, we are finally ready to install packages. First, we will need Flask.

pip install Flask

I’ll be using SQLAlchemy and Alembic for database creation and migration so I will install those for future use.

pip install Flask-Migrate
pip install Flask-Alembic 

Okay, time to generate a requirements file so we can easily install our packages on another machine.

pip freeze > requirements.txt 

Here is what our requirements file looks:

alembic==1.0.8
Click==7.0
Flask==1.0.2
Flask-Alembic==2.0.1
Flask-Migrate==2.4.0
Flask-SQLAlchemy==2.3.2
itsdangerous==1.1.0
Jinja2==2.10
Mako==1.0.8
MarkupSafe==1.1.1
python-dateutil==2.8.0
python-editor==1.0.4
six==1.12.0
SQLAlchemy==1.3.1
Werkzeug==0.15.1

Pushing to GitHub

All that’s left for now is to push what we have done so far up to GitHub.

git add .
git commit -m "init commit"
git push origin master

In part two, we will build a Hello World application.

You may also like

Leave a comment

This website uses cookies to improve your experience. We'll assume you're ok with this, but you can opt-out if you wish. Accept