Build and Deploy a Python Web App to Amazon in 30 Mins
-
Upload
jeff-hull -
Category
Technology
-
view
9.536 -
download
0
Transcript of Build and Deploy a Python Web App to Amazon in 30 Mins
Build and Deploy a Web Application in 30 Minutes
August 23rd, 2012 @kLabKigali, Rwanda
Jeff [email protected]/jsh2134
In 30 Minutes we will
Create an App
Deploy a Server
Launch the App
Pro Tip: You can fork the finished code here http://github.com/jsh2134/thirty-min-app
Who Are You?
Buzzient Social CRM and AnalyticsDev Manager and Lead Engineer
100K Lines of Code, 15 Servers, 24/7 Ops
Recruited and Managed team of 4+ Engineers
My Ivy Leaguer Test Prep and Tutoring ServiceCo-Founder and Lead Developer
Built Tutor/Client CRM software
Compete.com Web AnalyticsSoftware Developer Intern
Built Ad Scraper that powered their Ad Impact product
No Really, Who Are You?
I like to Build things (on the Internet)
The Internet is perfectFor Creation
For Distribution
For Disruption
For Monetization
For Success
For Failure
For LOLcats
Startups are like jumping out of a plane and figuring out how to
build the parachute as you fall.
-- Someone Smart
Learn by Experience
Write CodeSo you can learn how good/bad it is
Share CodeSo someone can tell you how good/bad it is
Deploy CodeSo the user can show you how good/bad it is
Best Advice: Just Dive In
Social CodingGitHub
StackOverflow
CoursesUdacity.com
CodeAcademy.com
Hacker News http://news.ycombinator.com
Code Tutorials, Startup News, Rants and Raves
The App
Pure Python
A Simple Flask App
Displays Facebook Images matching a word
Use Twitter Bootstrap for Style
Use Git for Version Control
Deploy to Amazon
The App
Lets get started...
Friends don't let Friends not use Git
Git is your friend
GitHub is your best friend
More Octocats at http://octodex.github.com
Lets git started
$ curl -u 'jsh2134' https://api.github.com/user/repos -d '{"name":"my_repo"}'$ git init my_repo$ cd my_repo$ git remote add origin [email protected]:jsh2134/my_repo$ vim README$ git add README$ git commit -m 'first commit'$ git push origin
What is Flask?
Lightweight Python web Framework
Like Django but SimplerUses all the best parts
~5000 Lines of CodeCan easily dig in if you need to debug or change
Leverages Jinja and WerkzeugWerkzeug debugger is incredible
The Simplest Flask App
from flask import Flaskapp = Flask(__name__)
@app.route('/')def hello_world(): return 'Hello World!'
if __name__ == '__main__': app.run()
And Now Some Flask Code
Jinja Templates
Separate the Python from the HTML
Add Logic to your HTML
Simple Syntax
Template Inheritance
Less gray hairs
Pause for Some Jinja Code
Boto
Python interface to Amazon Web Services
Create/Start/Stop Servers on DemandCan do everything actually
Boto is @&$?ing awesome
Actively Developed
AWS very Flexible
A Quick Boto Break
Fabric
Execute commands on remote server
Installation Scripts
Update Code
System Admin Tasks
We will use Fabric to deploy our app
Fabric Examples
The Final Code Base
__init__.pysettings.pyapp.pyec2.pyfabfile.pyrequirements.txttemplates/photos.htmlstatic/css/bootstrap.css
Deploy the Code
Finito
Fork this on Githubhttp://github.com/jsh2134/thirty-min-app
Contact@jsh2134
www.engineerwithoutacause.com
Slides will be posted online shortly