Skip to content

inclusiveThinking/twohourpythonworkshop

 
 

Repository files navigation

#Two Hour Python Hacker

2 hours from now we hope to have a small application on the cloud!

There are a number of things we want to accomplish today.

  1. Install Python
  2. use the REPL
  3. Run our first program
  4. Install a package - (Flask)
  5. Uninstall a package
  6. Install virtualenv
  7. Install virtualenvwrapper or virtualenvwrapper-win
  8. Create a virtual environment
  9. Install flask and run our first app
  10. Get access to an API
  11. Create a webapp
  12. Deploy

#Let's do this

1. Install Python

Windows

Mac

2. use the REPL

The REPL stands for Read Evaluate Print Loop

Makes iterating and testing easy!

python

'>>>'

try these commands:

x = 2 + 2

print x

import this

More Practice

3. Run our first program

Use your favorite text editor. I'm using Visual Studio Code

beginnings.py

sentence = "Four score and seven years ago"
sentence_no_vowels = ""
for letter in sentence: 
    if letter not in "AEIOUaeiou":
        sentence_no_vowels = sentence_no_vowels + letter
         
print sentence_no_vowels

4. Install a package

Python Packages are installed with pip

We'll install requests

pip -v

pip install requests

5. Uninstall a package

pip uninstall requests

6. Install virtualenv

pip install virtualenv

7. Install virtualenvwrapper or virtualenvwrapper-win

virtualenv wrappers make it easy to manage multiple environments and can make iterating on project easy.

Windows

Mac

8. Create a virtual environment

mkvirtualenv helloworld

cd into root of project

setprojectdir .

deactivate

workon helloworld

9. Install flask and run our first app

Now we need flask for our first website!

pip install flask

Create our hello.py

from flask import Flask
app = Flask(__name__)

@app.route("/")
def hello():
    return "Hello World!"

if __name__ == "__main__":
    app.run()

SWEET!

python hello.py
 * Running on http://localhost:5000/

10. Get access to an API

Bing Search

Project Oxford

11. Create a webapp

We'll start from a project I've already built:

My Guide for Azure

12. Deploy

GIT deploy! Same Guide as above

WEEEE!

Please contact me if you have any questions: @timmyreilly

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages

  • Python 63.5%
  • Batchfile 31.2%
  • HTML 5.2%
  • CSS 0.1%