#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.
- Install Python
- use the REPL
- Run our first program
- Install a package - (Flask)
- Uninstall a package
- Install virtualenv
- Install virtualenvwrapper or virtualenvwrapper-win
- Create a virtual environment
- Install flask and run our first app
- Get access to an API
- Create a webapp
- Deploy
#Let's do this
The REPL stands for Read Evaluate Print Loop
Makes iterating and testing easy!
python
'>>>'
try these commands:
x = 2 + 2
print x
import this
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_vowelsPython Packages are installed with pip
We'll install requests
pip -v
pip install requests
pip uninstall requests
pip install virtualenv
virtualenv wrappers make it easy to manage multiple environments and can make iterating on project easy.
mkvirtualenv helloworld
cd into root of project
setprojectdir .
deactivate
workon helloworld
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/
We'll start from a project I've already built:
GIT deploy! Same Guide as above
Please contact me if you have any questions: @timmyreilly