This workshop will walk you through how to build and deploy a simple Python app that serves a simple webpage that fetches data from the Google Maps API.
Scaffolding for the project, and a basic main.py
. Throughout this workshop, we'll be actually writing code! This branch serves as the base for what we'll be building off of. Starting off, we won't be touching the templates
and static
folders for now, so don't worry about those.
-
Installing Python
We will be usingPython 3.6.5
for this workshop. If you have another version of Python, it should still work but you may run into dependency issues. Here's the link to the download for Python 3. Check if you've installed it properly by making sure you can runpython
andpip
in the terminal. -
Installing Git
Git is a version control tool. You'll use this to download the repository and switch between branches! You can download the command line version here https://git-scm.com/downloads or if you prefer the GUI, https://www.gitkraken.com/ -
Project setup
Clone this project somewhere convenient. You can do this by opening your command prompt and navigating to a convenient folder.
e.g.cd ~/Documents
Thengit clone https://github.com/jackyzha0/lhd-build-python-webapp
and change directory into the foldercd lhd-build-python-webapp
. -
Installing dependencies
There are a few Python libraries we will be using today that will help us build today's app.
pip install flask requests
-
API Keys
Near the end of the workshop, we'll be integrating our app with the Google Maps API. Go ahead and get that key here: https://developers.google.com/places/web-service/get-api-key. Follow the 5 steps to get your API key. Create a file calledsecrets.txt
with your API key and put that in this folder. You'll need it later!
What is a backend?
"Backend" code is the stuff that powers everything on the internet from behind the scenes.
What is Flask?
Flask is a web framework written in python. Basically, it gives you the basic tools to build a web application, meaning you can serve websites and other cool stuff.
Getting started
Great, so how do I get started? If you've set up the project properly, you should find the main.py
file in the folder. Open it up with your editor of choice. We've provided 3 examples in the file. We can get our Flask
server up and running by executing python main.py
.