SlideShare a Scribd company logo
Build a
Python Web
APP
Ingredients
• Python
• Web server framework
• Database
• Love
Bottle + GEvent
• Async is cool
• More efficientuse of CPU
• Best for I/O-boundapplications
Install Bottle + Gevent
pip install gevent
pip install bottle
easy_install gevent
easy_install bottle
Hello World
from gevent import monkey; monkey.patch_all()
from bottle import run, route
@route('/hello')
def fxn():
return "Hello World!"
run(server='gevent', host="localhost", port=8001, debug=True)
unfbnjm
Step
Import gevent and bottle
Magicallyreplace synchronouslibrarieswith async
counterparts
from gevent import monkey;
monkey.patch_all()
from bottle import run, route
Step
Assign theurl /hello to thefunctionbelow
@route('/hello')
Define a pythonfunction
def fxn():
Return “HelloWorld!” to the browser
return "Hello World!"
Activate the gevent server, listen on port 8001
run(server='gevent', host="localhost", port=8001,
debug=True)
Accepting Inputs
Via theurl
http://www.gloopgroup.com/profile/paolo
Via query string
https://www.google.com.ph/?ion=1&q=gloopgroup
Via POSTbody
File upload to a website
Inputs in Bottle
Via theurl
@route('/input1/<name>')
def greet(name):
return "Hello "+name
Visit:localhost:8001/input1/paolo
Inputs in Bottle
Via query string
@route('/sum')
def sum():
total = 0
start = request.query.get("start")
end = request.query.get("end")
for i in range(start,end):
total += i
return "Sum of "+str(start) + " to " + str(end) + " = " +
str(total)
Visit: localhost:8001/sum?start=1&end=10
Inputs in Bottle
Via POST body
@route('/login', method="POST")
def login():
username = request.forms.get("username")
password = request.forms.get("password")
acceptedpasswords = ["gloopgroup", "devconph" ,
"adventuretime"]
if password in acceptedpasswords:
return "Welcome "+ username
else:
return "Unauthorized"
Visit: localhost:8001/login using login page
Activity 1
Create a calculatorapi:
http://localhost:8001/operation/operand1/operand2
will return the value of
operand1 <operation> operand2
Example:
/subtraction/10/2 will output 8
Common Return TYPES
PlainText
Similar to whatwe were doing earlier
Common Return TYPES
Binary
Whenreturning fileslike images, video, audio, pdfs…
Common Return TYPES
JSON
The common return type for APIs
Example:FB API
/{userid}/friends
{
"data": [
{
"name": "Terence Pua",
"id": "608407"
},
{
"name": "Gene Paul Quevedo",
"id": "10153785024974240"
},
{
"name": "Jc Velasquez",
"id": "722462218"
},
{
"name": "Jomel C. Imperio",
"id": "779287017"
}
],
"summary": {
"total_count": 770
}
}
Common Return TYPES
HTML
Returnweb pages with dynamic/static content
<!DOCTYPE html>
<html itemscope itemtype="http://schema.org/QAPage">
<head>
<title>regex - Validate email address in JavaScript? - Stack Overflow</title>
<link rel="shortcut icon" href="//cdn.sstatic.net/Sites/stackoverflow/img/favicon.ico?v=4f32ecc8f43d">
<link rel="apple-touch-icon image_src" href="//cdn.sstatic.net/Sites/stackoverflow/img/apple-touch-icon.png?v=c78bd457575a">
<link rel="search" type="application/opensearchdescription+xml" title="Stack Overflow" href="/opensearch.xml">
<meta name="twitter:card" content="summary">
<meta name="twitter:domain" content="stackoverflow.com"/>
<meta property="og:type" content="website" />
<meta property="og:image" itemprop="image primaryImageOfPage" content="http://cdn.sstatic.net/Sites/stackoverflow/img/apple-
touch-icon@2.png?v=73d79a89bded&a" />
<meta name="twitter:title" property="og:title" itemprop="title name" content="Validate email address in JavaScript?" />
<meta name="twitter:description" property="og:description" itemprop="description" content="How can an email address be validated
in JavaScript?" />
<meta property="og:url" content="http://stackoverflow.com/questions/46155/validate-email-address-in-javascript"/>
<link rel="canonical" href="http://stackoverflow.com/questions/46155/validate-email-address-in-javascript" />
Returning JSON Object
JSON
Simplyreturn a dictionary or list
@route("/json")
def jason():
return {"lastname":"bourne", "alias":"David Webb"}
Returning Static HTML
HTML
Use static_file from bottle
@route("/loginpage")
def loginpage():
return static_file("login.html", root=".")
Testing the POST Handler
Visit localhost:8081/loginpage
Type your nameand use any of theseas passwordg
gloopgroup, devconph, adventuretime
Click submit
The POST Request Cycle
<form action="/login" method="POST">
Method dictates what kind of request happens when submitted
Action tells the browser where to submit the request
<input type="text" name="username">
Adds a text input that will be associated to the username field
<input type="password" name="password">
Adds a password inputthat willbe associatedto the password field
<input type="submit">
Adds a button that submits the form whenclicked
Returning Dynamic HTML
HTML
Use a templatingengine:
• Library thatcan substitutevariables intoa templatequickly and cleanly
• Isolates thedesigner’s job of designing and thecoder’s job of coding
Install Tenjin
pip install tenjin
easy_install tenjin
Using Tenjin
from gevent import monkey;
monkey.patch_all()
from bottle import run, route, request
import tenjin
from tenjin.helpers import *
@route("/introduction/<name>/<age>/<work>")
def template1(name, age, work):
context = {"name":name, "age":age, "work":work}
return engine.render("introduction.html", context);
engine = tenjin.Engine(path=['.'])
run(server='gevent', host="localhost", port=8001, debug=True)
The template
<!doctype html>
<html lang="en">
<head>
<title>Login</title>
</head>
<body>
<h1>${name}</h1>
<h2>Age:${age}<h2>
<h2>Work:${work}<h2>
</body>
</html>
Step
from gevent import monkey;
monkey.patch_all()
from bottle import run, route, request
import tenjin
from tenjin.helpers import *
Import alllibraries, including tenjin and all helper methods
@route("/introduction/<name>/<age>/<work>")
Define a route for the url, and define variables in it
def template1(name, age, work):
Declare a request handler and receive the variables from the url
Step
context = {"name":name, "age":age, "work":work}
Define a context variable, which is a dictionary of values that will be substituted into the template
return engine.render("introduction.html", context);
Render the template called introduction.html using the context variable named context, and return it to
the browser
engine = tenjin.Engine(path=['.'])
Instructs the templating engine to look for the templates in the directories listed in path
Step (Inside the template)
<!doctype html>
<html lang="en">
<head>
<title>Login</title>
</head>
<body>
<h1>${name}</h1>
<h2>Age:${age}<h2>
<h2>Work:${work}<h2>
</body>
</html>
{
"name":"Paolo",
"age":"30",
"work":"Synergist"
}
+
Displaying Lists
@route("/spell/<word>")
def template1(word):
letters = list(word)
context = {"letters":letters, "word":word}
return engine.render("speller.html", context);
Step
@route("/spell/<word>")
Define a route that accepts a variable assigned to word
def speller(word):
Define a handler that accepts avariable named word
letters = list(word)
Convert the text string into a listobject. From a string “word”, it becomes a list [“w”, “o”, “r”, “d”]
Step
context = {"letters":letters}
Define a context variable, which contains the listof letters we just created
return engine.render("speller.html", context);
Render the template called speller.html using the context variable named context, and return it to the
browser
Step (Inside the template)
<?py for letter in letters: ?>
Loop on the elements of the list named letters
<h3>${letter}</h3><br>
Display the element letter along with the html
<?py #endfor ?>
Denote where the loop ends inthe template
<a href="/greet/${word}">greet ${word}</a>
Create a link that willcall the greet API we created earlier
{"letters":["s", "u", "s", "h", "i"]}
Highlighting Names
@route("/profiles/<name>")
def profile(name):
users = [
{"name":"Em", "image":"http://goo.gl/aDxeu1", "age":30,
"work":"Futurist"},
{"name":"Paolo", "image":"http://goo.gl/5k2oZr", "age":30,
"work":"Synergist"}
]
context = {"users":users, "name":name}
return engine.render("profiles.html", context)
Step
users = [
{"name":"Em", "image":"http://goo.gl/aDxeu1", "age":30, "work":"Futurist"},
{"name":"Paolo", "image":"http://goo.gl/5k2oZr", "age":30, "work":"Synergist"}
]
Define a list of dictionaries, with each dictionary objectcontaining information about a user. It contains information
name,url of the image, age, and work
context = {"users":users, "name":name}
Define a conext containing the name to behighlighted, and the list of users
return engine.render("profiles.html", context)
Render the template named profiles.html with the context
Step (Inside the template)
<?py for user in users: ?>
Loop on the elements of the list named users, each element in the listcan be referred to using the user
variable
<div style="height:100px;">
Create a div element in the html to contain one user element
<img src="${user['image']}" style="float:left;
height:100%;"/>
Place an image in the html coming from the url defined in user[‘image’]
Step (Inside the template)
<?py if name==user["name"]: ?>
Compare the current user’s name to the name entered in the url
<strong>Name: ${user['name']}</strong>
Thishappens when the above condition istrue, display the name asbold characters
<?py else: ?>
Add an else handler that executes if condition is not met
Step (Inside the template)
Name: ${user['name']}
This happens when primary condition is not met, display the user’s name without any decorations
<?py #endif ?>
Denote where the if statement ends
Make a Sushi Menu
Create a menu using allthe sushiitems in the sushilistvariable
Display the image and name of the sushi
When the menu item is clicked, it should display another page containingthe name, image, price, and
rating of the sushi(defined in the sushilistvariable)
The most creative presentation of the menu wins aprize
Activity 1
pip install gevent
pip install bottle
Cost per Mille =
• Cost per 1000 impressions
• Abuse of statistics
• i.e. Magic
• i.e. It sucks
• Not based on empirical measured data
ADVERTISING!
Eyeballs
cost
How many are watching
me right now?
How many are paying attention?
How many are interested?
How many are still reading this part?
How about now?
Now?
Python Code Camp for Professionals 1/4
ROUTER ON
PROMISCUOUS MODE
DEVICEs SENDING
PROBE REQUESTS
PYTHON
+TCPDUMP
We get this
Pilot Installation
23000
Passers-by
39%
viewed
10%
Finished
Meh…
Map movement
Geofencing alternative
Detection
perimeter
snoop
turn off your phones
when going to the lagoon
Ad

More Related Content

What's hot (20)

Flask - Backend com Python - Semcomp 18
Flask - Backend com Python - Semcomp 18Flask - Backend com Python - Semcomp 18
Flask - Backend com Python - Semcomp 18
Lar21
 
Flask patterns
Flask patternsFlask patterns
Flask patterns
it-people
 
REST with Eve and Python
REST with Eve and PythonREST with Eve and Python
REST with Eve and Python
PiXeL16
 
OSCON Google App Engine Codelab - July 2010
OSCON Google App Engine Codelab - July 2010OSCON Google App Engine Codelab - July 2010
OSCON Google App Engine Codelab - July 2010
ikailan
 
Filling the flask
Filling the flaskFilling the flask
Filling the flask
Jason Myers
 
RESTFUL SERVICES MADE EASY: THE EVE REST API FRAMEWORK - Nicola Iarocci - Co...
RESTFUL SERVICES MADE EASY: THE EVE REST API FRAMEWORK -  Nicola Iarocci - Co...RESTFUL SERVICES MADE EASY: THE EVE REST API FRAMEWORK -  Nicola Iarocci - Co...
RESTFUL SERVICES MADE EASY: THE EVE REST API FRAMEWORK - Nicola Iarocci - Co...
Codemotion
 
Rails 3: Dashing to the Finish
Rails 3: Dashing to the FinishRails 3: Dashing to the Finish
Rails 3: Dashing to the Finish
Yehuda Katz
 
Incremental Type Safety in React Apollo
Incremental Type Safety in React Apollo Incremental Type Safety in React Apollo
Incremental Type Safety in React Apollo
Evans Hauser
 
Remote controlling Parrot AR Drone with Spring Boot & Vaadin (JavaCro15)
Remote controlling Parrot AR Drone with Spring Boot & Vaadin (JavaCro15)Remote controlling Parrot AR Drone with Spring Boot & Vaadin (JavaCro15)
Remote controlling Parrot AR Drone with Spring Boot & Vaadin (JavaCro15)
Peter Lehto
 
Html5 For Jjugccc2009fall
Html5 For Jjugccc2009fallHtml5 For Jjugccc2009fall
Html5 For Jjugccc2009fall
Shumpei Shiraishi
 
Graphql, REST and Apollo
Graphql, REST and ApolloGraphql, REST and Apollo
Graphql, REST and Apollo
Christoffer Noring
 
Flask – Python
Flask – PythonFlask – Python
Flask – Python
Max Claus Nunes
 
TurboGears2 Pluggable Applications
TurboGears2 Pluggable ApplicationsTurboGears2 Pluggable Applications
TurboGears2 Pluggable Applications
Alessandro Molina
 
Advanced Django
Advanced DjangoAdvanced Django
Advanced Django
Simon Willison
 
GWT integration with Vaadin
GWT integration with VaadinGWT integration with Vaadin
GWT integration with Vaadin
Peter Lehto
 
Jsp/Servlet
Jsp/ServletJsp/Servlet
Jsp/Servlet
Sunil OS
 
Rails 3 overview
Rails 3 overviewRails 3 overview
Rails 3 overview
Yehuda Katz
 
Keeping the frontend under control with Symfony and Webpack
Keeping the frontend under control with Symfony and WebpackKeeping the frontend under control with Symfony and Webpack
Keeping the frontend under control with Symfony and Webpack
Ignacio Martín
 
jQuery in 15 minutes
jQuery in 15 minutesjQuery in 15 minutes
jQuery in 15 minutes
Simon Willison
 
Developing application for Windows Phone 7 in TDD
Developing application for Windows Phone 7 in TDDDeveloping application for Windows Phone 7 in TDD
Developing application for Windows Phone 7 in TDD
Michele Capra
 
Flask - Backend com Python - Semcomp 18
Flask - Backend com Python - Semcomp 18Flask - Backend com Python - Semcomp 18
Flask - Backend com Python - Semcomp 18
Lar21
 
Flask patterns
Flask patternsFlask patterns
Flask patterns
it-people
 
REST with Eve and Python
REST with Eve and PythonREST with Eve and Python
REST with Eve and Python
PiXeL16
 
OSCON Google App Engine Codelab - July 2010
OSCON Google App Engine Codelab - July 2010OSCON Google App Engine Codelab - July 2010
OSCON Google App Engine Codelab - July 2010
ikailan
 
Filling the flask
Filling the flaskFilling the flask
Filling the flask
Jason Myers
 
RESTFUL SERVICES MADE EASY: THE EVE REST API FRAMEWORK - Nicola Iarocci - Co...
RESTFUL SERVICES MADE EASY: THE EVE REST API FRAMEWORK -  Nicola Iarocci - Co...RESTFUL SERVICES MADE EASY: THE EVE REST API FRAMEWORK -  Nicola Iarocci - Co...
RESTFUL SERVICES MADE EASY: THE EVE REST API FRAMEWORK - Nicola Iarocci - Co...
Codemotion
 
Rails 3: Dashing to the Finish
Rails 3: Dashing to the FinishRails 3: Dashing to the Finish
Rails 3: Dashing to the Finish
Yehuda Katz
 
Incremental Type Safety in React Apollo
Incremental Type Safety in React Apollo Incremental Type Safety in React Apollo
Incremental Type Safety in React Apollo
Evans Hauser
 
Remote controlling Parrot AR Drone with Spring Boot & Vaadin (JavaCro15)
Remote controlling Parrot AR Drone with Spring Boot & Vaadin (JavaCro15)Remote controlling Parrot AR Drone with Spring Boot & Vaadin (JavaCro15)
Remote controlling Parrot AR Drone with Spring Boot & Vaadin (JavaCro15)
Peter Lehto
 
TurboGears2 Pluggable Applications
TurboGears2 Pluggable ApplicationsTurboGears2 Pluggable Applications
TurboGears2 Pluggable Applications
Alessandro Molina
 
GWT integration with Vaadin
GWT integration with VaadinGWT integration with Vaadin
GWT integration with Vaadin
Peter Lehto
 
Jsp/Servlet
Jsp/ServletJsp/Servlet
Jsp/Servlet
Sunil OS
 
Rails 3 overview
Rails 3 overviewRails 3 overview
Rails 3 overview
Yehuda Katz
 
Keeping the frontend under control with Symfony and Webpack
Keeping the frontend under control with Symfony and WebpackKeeping the frontend under control with Symfony and Webpack
Keeping the frontend under control with Symfony and Webpack
Ignacio Martín
 
Developing application for Windows Phone 7 in TDD
Developing application for Windows Phone 7 in TDDDeveloping application for Windows Phone 7 in TDD
Developing application for Windows Phone 7 in TDD
Michele Capra
 

Similar to Python Code Camp for Professionals 1/4 (20)

Django crush course
Django crush course Django crush course
Django crush course
Mohammed El Rafie Tarabay
 
Building iPhone Web Apps using "classic" Domino
Building iPhone Web Apps using "classic" DominoBuilding iPhone Web Apps using "classic" Domino
Building iPhone Web Apps using "classic" Domino
Rob Bontekoe
 
Django Rest Framework and React and Redux, Oh My!
Django Rest Framework and React and Redux, Oh My!Django Rest Framework and React and Redux, Oh My!
Django Rest Framework and React and Redux, Oh My!
Eric Palakovich Carr
 
Gae Meets Django
Gae Meets DjangoGae Meets Django
Gae Meets Django
fool2nd
 
Angular JS2 Training Session #2
Angular JS2 Training Session #2Angular JS2 Training Session #2
Angular JS2 Training Session #2
Paras Mendiratta
 
HTML5 New and Improved
HTML5   New and ImprovedHTML5   New and Improved
HTML5 New and Improved
Timothy Fisher
 
Django at the Disco
Django at the DiscoDjango at the Disco
Django at the Disco
Richard Leland
 
An Introduction to Tornado
An Introduction to TornadoAn Introduction to Tornado
An Introduction to Tornado
Gavin Roy
 
Django Class-based views (Slovenian)
Django Class-based views (Slovenian)Django Class-based views (Slovenian)
Django Class-based views (Slovenian)
Luka Zakrajšek
 
Backbone.js — Introduction to client-side JavaScript MVC
Backbone.js — Introduction to client-side JavaScript MVCBackbone.js — Introduction to client-side JavaScript MVC
Backbone.js — Introduction to client-side JavaScript MVC
pootsbook
 
Angular를 활용한 웹 프론트단 개발과 2.0에서 달라진점
Angular를 활용한 웹 프론트단 개발과 2.0에서 달라진점 Angular를 활용한 웹 프론트단 개발과 2.0에서 달라진점
Angular를 활용한 웹 프론트단 개발과 2.0에서 달라진점
WebFrameworks
 
Angular를 활용한 웹 프론트단 개발과 2.0에서 달라진점
Angular를 활용한 웹 프론트단 개발과 2.0에서 달라진점Angular를 활용한 웹 프론트단 개발과 2.0에서 달라진점
Angular를 활용한 웹 프론트단 개발과 2.0에서 달라진점
Jeado Ko
 
Introduction to Django
Introduction to DjangoIntroduction to Django
Introduction to Django
Joaquim Rocha
 
JSP
JSPJSP
JSP
corneliuskoo
 
WordPress as the Backbone(.js)
WordPress as the Backbone(.js)WordPress as the Backbone(.js)
WordPress as the Backbone(.js)
Beau Lebens
 
Django at the Disco
Django at the DiscoDjango at the Disco
Django at the Disco
Richard Leland
 
Django at the Disco
Django at the DiscoDjango at the Disco
Django at the Disco
Richard Leland
 
Django at the Disco
Django at the DiscoDjango at the Disco
Django at the Disco
Richard Leland
 
Django at the Disco
Django at the DiscoDjango at the Disco
Django at the Disco
Richard Leland
 
PHPConf-TW 2012 # Twig
PHPConf-TW 2012 # TwigPHPConf-TW 2012 # Twig
PHPConf-TW 2012 # Twig
Wake Liu
 
Building iPhone Web Apps using "classic" Domino
Building iPhone Web Apps using "classic" DominoBuilding iPhone Web Apps using "classic" Domino
Building iPhone Web Apps using "classic" Domino
Rob Bontekoe
 
Django Rest Framework and React and Redux, Oh My!
Django Rest Framework and React and Redux, Oh My!Django Rest Framework and React and Redux, Oh My!
Django Rest Framework and React and Redux, Oh My!
Eric Palakovich Carr
 
Gae Meets Django
Gae Meets DjangoGae Meets Django
Gae Meets Django
fool2nd
 
Angular JS2 Training Session #2
Angular JS2 Training Session #2Angular JS2 Training Session #2
Angular JS2 Training Session #2
Paras Mendiratta
 
HTML5 New and Improved
HTML5   New and ImprovedHTML5   New and Improved
HTML5 New and Improved
Timothy Fisher
 
An Introduction to Tornado
An Introduction to TornadoAn Introduction to Tornado
An Introduction to Tornado
Gavin Roy
 
Django Class-based views (Slovenian)
Django Class-based views (Slovenian)Django Class-based views (Slovenian)
Django Class-based views (Slovenian)
Luka Zakrajšek
 
Backbone.js — Introduction to client-side JavaScript MVC
Backbone.js — Introduction to client-side JavaScript MVCBackbone.js — Introduction to client-side JavaScript MVC
Backbone.js — Introduction to client-side JavaScript MVC
pootsbook
 
Angular를 활용한 웹 프론트단 개발과 2.0에서 달라진점
Angular를 활용한 웹 프론트단 개발과 2.0에서 달라진점 Angular를 활용한 웹 프론트단 개발과 2.0에서 달라진점
Angular를 활용한 웹 프론트단 개발과 2.0에서 달라진점
WebFrameworks
 
Angular를 활용한 웹 프론트단 개발과 2.0에서 달라진점
Angular를 활용한 웹 프론트단 개발과 2.0에서 달라진점Angular를 활용한 웹 프론트단 개발과 2.0에서 달라진점
Angular를 활용한 웹 프론트단 개발과 2.0에서 달라진점
Jeado Ko
 
Introduction to Django
Introduction to DjangoIntroduction to Django
Introduction to Django
Joaquim Rocha
 
WordPress as the Backbone(.js)
WordPress as the Backbone(.js)WordPress as the Backbone(.js)
WordPress as the Backbone(.js)
Beau Lebens
 
PHPConf-TW 2012 # Twig
PHPConf-TW 2012 # TwigPHPConf-TW 2012 # Twig
PHPConf-TW 2012 # Twig
Wake Liu
 
Ad

More from DEVCON (20)

Open Minded? Software Engineer to a UX Engineer. Ask me how. by Micael Diaz d...
Open Minded? Software Engineer to a UX Engineer. Ask me how. by Micael Diaz d...Open Minded? Software Engineer to a UX Engineer. Ask me how. by Micael Diaz d...
Open Minded? Software Engineer to a UX Engineer. Ask me how. by Micael Diaz d...
DEVCON
 
The A1 by Christian John Felix
The A1 by Christian John FelixThe A1 by Christian John Felix
The A1 by Christian John Felix
DEVCON
 
Developing Your First Mobile VR App by NJ Realubit
Developing Your First Mobile VR App by NJ RealubitDeveloping Your First Mobile VR App by NJ Realubit
Developing Your First Mobile VR App by NJ Realubit
DEVCON
 
Smart Waste Disposal System by Russ Earl Malangen
Smart Waste Disposal System by Russ Earl MalangenSmart Waste Disposal System by Russ Earl Malangen
Smart Waste Disposal System by Russ Earl Malangen
DEVCON
 
Progressive Web Apps by Millicent Convento
Progressive Web Apps by Millicent ConventoProgressive Web Apps by Millicent Convento
Progressive Web Apps by Millicent Convento
DEVCON
 
How to Prevent Design Blindness by Tin Balabat
How to Prevent Design Blindness by Tin BalabatHow to Prevent Design Blindness by Tin Balabat
How to Prevent Design Blindness by Tin Balabat
DEVCON
 
Payment Acceptance and Card Tokenization in JavaScript by Diwa Del Mundo
Payment Acceptance and Card Tokenization in JavaScript by Diwa Del MundoPayment Acceptance and Card Tokenization in JavaScript by Diwa Del Mundo
Payment Acceptance and Card Tokenization in JavaScript by Diwa Del Mundo
DEVCON
 
Solving Database Management, Migration, and Scaling Problems with DevOps Tool...
Solving Database Management, Migration, and Scaling Problems with DevOps Tool...Solving Database Management, Migration, and Scaling Problems with DevOps Tool...
Solving Database Management, Migration, and Scaling Problems with DevOps Tool...
DEVCON
 
Securing Your AWS Cloud Infrastructure by Neil Hermosilla
Securing Your AWS Cloud Infrastructure by Neil HermosillaSecuring Your AWS Cloud Infrastructure by Neil Hermosilla
Securing Your AWS Cloud Infrastructure by Neil Hermosilla
DEVCON
 
Talk nerdy to me: how the future of UX is conversation and bots by Brian Rowe
Talk nerdy to me: how the future of UX is conversation and bots by Brian RoweTalk nerdy to me: how the future of UX is conversation and bots by Brian Rowe
Talk nerdy to me: how the future of UX is conversation and bots by Brian Rowe
DEVCON
 
Pokemon Go Analysis by Jolo Balbin
Pokemon Go Analysis by Jolo BalbinPokemon Go Analysis by Jolo Balbin
Pokemon Go Analysis by Jolo Balbin
DEVCON
 
Docker - Contain that Wild Application by Marvin Arcilla
Docker - Contain that Wild Application by Marvin ArcillaDocker - Contain that Wild Application by Marvin Arcilla
Docker - Contain that Wild Application by Marvin Arcilla
DEVCON
 
Applying Machine Learning for Mobile Games by Neil Patrick Del Gallego
Applying Machine Learning for Mobile Games by Neil Patrick Del GallegoApplying Machine Learning for Mobile Games by Neil Patrick Del Gallego
Applying Machine Learning for Mobile Games by Neil Patrick Del Gallego
DEVCON
 
Quick prototyping (Construct 2 & Unity) by Roan Contreras
Quick prototyping (Construct 2 & Unity) by Roan ContrerasQuick prototyping (Construct 2 & Unity) by Roan Contreras
Quick prototyping (Construct 2 & Unity) by Roan Contreras
DEVCON
 
A Smarter World: The Mesh of Interconnected Devices and Artificial Intelligen...
A Smarter World: The Mesh of Interconnected Devices and Artificial Intelligen...A Smarter World: The Mesh of Interconnected Devices and Artificial Intelligen...
A Smarter World: The Mesh of Interconnected Devices and Artificial Intelligen...
DEVCON
 
Creating a Hospital Based IoT Solution by Russ Earl Malangen
Creating a Hospital Based IoT Solution by Russ Earl MalangenCreating a Hospital Based IoT Solution by Russ Earl Malangen
Creating a Hospital Based IoT Solution by Russ Earl Malangen
DEVCON
 
Developing a Smart Farm: Using Low-Cost electronics and a Civil Engineering B...
Developing a Smart Farm: Using Low-Cost electronics and a Civil Engineering B...Developing a Smart Farm: Using Low-Cost electronics and a Civil Engineering B...
Developing a Smart Farm: Using Low-Cost electronics and a Civil Engineering B...
DEVCON
 
Rain Classifier: The Engineered Way of Evaluating the Rain by Paulo Luis Lozano
Rain Classifier: The Engineered Way of Evaluating the Rain by Paulo Luis LozanoRain Classifier: The Engineered Way of Evaluating the Rain by Paulo Luis Lozano
Rain Classifier: The Engineered Way of Evaluating the Rain by Paulo Luis Lozano
DEVCON
 
Fundamentals of IoT: Communications with Uttr by Edmandie Samonte
Fundamentals of IoT: Communications with Uttr by Edmandie SamonteFundamentals of IoT: Communications with Uttr by Edmandie Samonte
Fundamentals of IoT: Communications with Uttr by Edmandie Samonte
DEVCON
 
Protocol-Oriented Programming in iOS: the Correct Way to Use Swift by JC Vela...
Protocol-Oriented Programming in iOS: the Correct Way to Use Swift by JC Vela...Protocol-Oriented Programming in iOS: the Correct Way to Use Swift by JC Vela...
Protocol-Oriented Programming in iOS: the Correct Way to Use Swift by JC Vela...
DEVCON
 
Open Minded? Software Engineer to a UX Engineer. Ask me how. by Micael Diaz d...
Open Minded? Software Engineer to a UX Engineer. Ask me how. by Micael Diaz d...Open Minded? Software Engineer to a UX Engineer. Ask me how. by Micael Diaz d...
Open Minded? Software Engineer to a UX Engineer. Ask me how. by Micael Diaz d...
DEVCON
 
The A1 by Christian John Felix
The A1 by Christian John FelixThe A1 by Christian John Felix
The A1 by Christian John Felix
DEVCON
 
Developing Your First Mobile VR App by NJ Realubit
Developing Your First Mobile VR App by NJ RealubitDeveloping Your First Mobile VR App by NJ Realubit
Developing Your First Mobile VR App by NJ Realubit
DEVCON
 
Smart Waste Disposal System by Russ Earl Malangen
Smart Waste Disposal System by Russ Earl MalangenSmart Waste Disposal System by Russ Earl Malangen
Smart Waste Disposal System by Russ Earl Malangen
DEVCON
 
Progressive Web Apps by Millicent Convento
Progressive Web Apps by Millicent ConventoProgressive Web Apps by Millicent Convento
Progressive Web Apps by Millicent Convento
DEVCON
 
How to Prevent Design Blindness by Tin Balabat
How to Prevent Design Blindness by Tin BalabatHow to Prevent Design Blindness by Tin Balabat
How to Prevent Design Blindness by Tin Balabat
DEVCON
 
Payment Acceptance and Card Tokenization in JavaScript by Diwa Del Mundo
Payment Acceptance and Card Tokenization in JavaScript by Diwa Del MundoPayment Acceptance and Card Tokenization in JavaScript by Diwa Del Mundo
Payment Acceptance and Card Tokenization in JavaScript by Diwa Del Mundo
DEVCON
 
Solving Database Management, Migration, and Scaling Problems with DevOps Tool...
Solving Database Management, Migration, and Scaling Problems with DevOps Tool...Solving Database Management, Migration, and Scaling Problems with DevOps Tool...
Solving Database Management, Migration, and Scaling Problems with DevOps Tool...
DEVCON
 
Securing Your AWS Cloud Infrastructure by Neil Hermosilla
Securing Your AWS Cloud Infrastructure by Neil HermosillaSecuring Your AWS Cloud Infrastructure by Neil Hermosilla
Securing Your AWS Cloud Infrastructure by Neil Hermosilla
DEVCON
 
Talk nerdy to me: how the future of UX is conversation and bots by Brian Rowe
Talk nerdy to me: how the future of UX is conversation and bots by Brian RoweTalk nerdy to me: how the future of UX is conversation and bots by Brian Rowe
Talk nerdy to me: how the future of UX is conversation and bots by Brian Rowe
DEVCON
 
Pokemon Go Analysis by Jolo Balbin
Pokemon Go Analysis by Jolo BalbinPokemon Go Analysis by Jolo Balbin
Pokemon Go Analysis by Jolo Balbin
DEVCON
 
Docker - Contain that Wild Application by Marvin Arcilla
Docker - Contain that Wild Application by Marvin ArcillaDocker - Contain that Wild Application by Marvin Arcilla
Docker - Contain that Wild Application by Marvin Arcilla
DEVCON
 
Applying Machine Learning for Mobile Games by Neil Patrick Del Gallego
Applying Machine Learning for Mobile Games by Neil Patrick Del GallegoApplying Machine Learning for Mobile Games by Neil Patrick Del Gallego
Applying Machine Learning for Mobile Games by Neil Patrick Del Gallego
DEVCON
 
Quick prototyping (Construct 2 & Unity) by Roan Contreras
Quick prototyping (Construct 2 & Unity) by Roan ContrerasQuick prototyping (Construct 2 & Unity) by Roan Contreras
Quick prototyping (Construct 2 & Unity) by Roan Contreras
DEVCON
 
A Smarter World: The Mesh of Interconnected Devices and Artificial Intelligen...
A Smarter World: The Mesh of Interconnected Devices and Artificial Intelligen...A Smarter World: The Mesh of Interconnected Devices and Artificial Intelligen...
A Smarter World: The Mesh of Interconnected Devices and Artificial Intelligen...
DEVCON
 
Creating a Hospital Based IoT Solution by Russ Earl Malangen
Creating a Hospital Based IoT Solution by Russ Earl MalangenCreating a Hospital Based IoT Solution by Russ Earl Malangen
Creating a Hospital Based IoT Solution by Russ Earl Malangen
DEVCON
 
Developing a Smart Farm: Using Low-Cost electronics and a Civil Engineering B...
Developing a Smart Farm: Using Low-Cost electronics and a Civil Engineering B...Developing a Smart Farm: Using Low-Cost electronics and a Civil Engineering B...
Developing a Smart Farm: Using Low-Cost electronics and a Civil Engineering B...
DEVCON
 
Rain Classifier: The Engineered Way of Evaluating the Rain by Paulo Luis Lozano
Rain Classifier: The Engineered Way of Evaluating the Rain by Paulo Luis LozanoRain Classifier: The Engineered Way of Evaluating the Rain by Paulo Luis Lozano
Rain Classifier: The Engineered Way of Evaluating the Rain by Paulo Luis Lozano
DEVCON
 
Fundamentals of IoT: Communications with Uttr by Edmandie Samonte
Fundamentals of IoT: Communications with Uttr by Edmandie SamonteFundamentals of IoT: Communications with Uttr by Edmandie Samonte
Fundamentals of IoT: Communications with Uttr by Edmandie Samonte
DEVCON
 
Protocol-Oriented Programming in iOS: the Correct Way to Use Swift by JC Vela...
Protocol-Oriented Programming in iOS: the Correct Way to Use Swift by JC Vela...Protocol-Oriented Programming in iOS: the Correct Way to Use Swift by JC Vela...
Protocol-Oriented Programming in iOS: the Correct Way to Use Swift by JC Vela...
DEVCON
 
Ad

Recently uploaded (20)

Linux Support for SMARC: How Toradex Empowers Embedded Developers
Linux Support for SMARC: How Toradex Empowers Embedded DevelopersLinux Support for SMARC: How Toradex Empowers Embedded Developers
Linux Support for SMARC: How Toradex Empowers Embedded Developers
Toradex
 
Splunk Security Update | Public Sector Summit Germany 2025
Splunk Security Update | Public Sector Summit Germany 2025Splunk Security Update | Public Sector Summit Germany 2025
Splunk Security Update | Public Sector Summit Germany 2025
Splunk
 
Complete Guide to Advanced Logistics Management Software in Riyadh.pdf
Complete Guide to Advanced Logistics Management Software in Riyadh.pdfComplete Guide to Advanced Logistics Management Software in Riyadh.pdf
Complete Guide to Advanced Logistics Management Software in Riyadh.pdf
Software Company
 
TrsLabs - Fintech Product & Business Consulting
TrsLabs - Fintech Product & Business ConsultingTrsLabs - Fintech Product & Business Consulting
TrsLabs - Fintech Product & Business Consulting
Trs Labs
 
Special Meetup Edition - TDX Bengaluru Meetup #52.pptx
Special Meetup Edition - TDX Bengaluru Meetup #52.pptxSpecial Meetup Edition - TDX Bengaluru Meetup #52.pptx
Special Meetup Edition - TDX Bengaluru Meetup #52.pptx
shyamraj55
 
Noah Loul Shares 5 Steps to Implement AI Agents for Maximum Business Efficien...
Noah Loul Shares 5 Steps to Implement AI Agents for Maximum Business Efficien...Noah Loul Shares 5 Steps to Implement AI Agents for Maximum Business Efficien...
Noah Loul Shares 5 Steps to Implement AI Agents for Maximum Business Efficien...
Noah Loul
 
What is Model Context Protocol(MCP) - The new technology for communication bw...
What is Model Context Protocol(MCP) - The new technology for communication bw...What is Model Context Protocol(MCP) - The new technology for communication bw...
What is Model Context Protocol(MCP) - The new technology for communication bw...
Vishnu Singh Chundawat
 
Dev Dives: Automate and orchestrate your processes with UiPath Maestro
Dev Dives: Automate and orchestrate your processes with UiPath MaestroDev Dives: Automate and orchestrate your processes with UiPath Maestro
Dev Dives: Automate and orchestrate your processes with UiPath Maestro
UiPathCommunity
 
#StandardsGoals for 2025: Standards & certification roundup - Tech Forum 2025
#StandardsGoals for 2025: Standards & certification roundup - Tech Forum 2025#StandardsGoals for 2025: Standards & certification roundup - Tech Forum 2025
#StandardsGoals for 2025: Standards & certification roundup - Tech Forum 2025
BookNet Canada
 
Drupalcamp Finland – Measuring Front-end Energy Consumption
Drupalcamp Finland – Measuring Front-end Energy ConsumptionDrupalcamp Finland – Measuring Front-end Energy Consumption
Drupalcamp Finland – Measuring Front-end Energy Consumption
Exove
 
HCL Nomad Web – Best Practices und Verwaltung von Multiuser-Umgebungen
HCL Nomad Web – Best Practices und Verwaltung von Multiuser-UmgebungenHCL Nomad Web – Best Practices und Verwaltung von Multiuser-Umgebungen
HCL Nomad Web – Best Practices und Verwaltung von Multiuser-Umgebungen
panagenda
 
ThousandEyes Partner Innovation Updates for May 2025
ThousandEyes Partner Innovation Updates for May 2025ThousandEyes Partner Innovation Updates for May 2025
ThousandEyes Partner Innovation Updates for May 2025
ThousandEyes
 
HCL Nomad Web – Best Practices and Managing Multiuser Environments
HCL Nomad Web – Best Practices and Managing Multiuser EnvironmentsHCL Nomad Web – Best Practices and Managing Multiuser Environments
HCL Nomad Web – Best Practices and Managing Multiuser Environments
panagenda
 
2025-05-Q4-2024-Investor-Presentation.pptx
2025-05-Q4-2024-Investor-Presentation.pptx2025-05-Q4-2024-Investor-Presentation.pptx
2025-05-Q4-2024-Investor-Presentation.pptx
Samuele Fogagnolo
 
Big Data Analytics Quick Research Guide by Arthur Morgan
Big Data Analytics Quick Research Guide by Arthur MorganBig Data Analytics Quick Research Guide by Arthur Morgan
Big Data Analytics Quick Research Guide by Arthur Morgan
Arthur Morgan
 
Andrew Marnell: Transforming Business Strategy Through Data-Driven Insights
Andrew Marnell: Transforming Business Strategy Through Data-Driven InsightsAndrew Marnell: Transforming Business Strategy Through Data-Driven Insights
Andrew Marnell: Transforming Business Strategy Through Data-Driven Insights
Andrew Marnell
 
Cyber Awareness overview for 2025 month of security
Cyber Awareness overview for 2025 month of securityCyber Awareness overview for 2025 month of security
Cyber Awareness overview for 2025 month of security
riccardosl1
 
Build Your Own Copilot & Agents For Devs
Build Your Own Copilot & Agents For DevsBuild Your Own Copilot & Agents For Devs
Build Your Own Copilot & Agents For Devs
Brian McKeiver
 
Transcript: #StandardsGoals for 2025: Standards & certification roundup - Tec...
Transcript: #StandardsGoals for 2025: Standards & certification roundup - Tec...Transcript: #StandardsGoals for 2025: Standards & certification roundup - Tec...
Transcript: #StandardsGoals for 2025: Standards & certification roundup - Tec...
BookNet Canada
 
AI EngineHost Review: Revolutionary USA Datacenter-Based Hosting with NVIDIA ...
AI EngineHost Review: Revolutionary USA Datacenter-Based Hosting with NVIDIA ...AI EngineHost Review: Revolutionary USA Datacenter-Based Hosting with NVIDIA ...
AI EngineHost Review: Revolutionary USA Datacenter-Based Hosting with NVIDIA ...
SOFTTECHHUB
 
Linux Support for SMARC: How Toradex Empowers Embedded Developers
Linux Support for SMARC: How Toradex Empowers Embedded DevelopersLinux Support for SMARC: How Toradex Empowers Embedded Developers
Linux Support for SMARC: How Toradex Empowers Embedded Developers
Toradex
 
Splunk Security Update | Public Sector Summit Germany 2025
Splunk Security Update | Public Sector Summit Germany 2025Splunk Security Update | Public Sector Summit Germany 2025
Splunk Security Update | Public Sector Summit Germany 2025
Splunk
 
Complete Guide to Advanced Logistics Management Software in Riyadh.pdf
Complete Guide to Advanced Logistics Management Software in Riyadh.pdfComplete Guide to Advanced Logistics Management Software in Riyadh.pdf
Complete Guide to Advanced Logistics Management Software in Riyadh.pdf
Software Company
 
TrsLabs - Fintech Product & Business Consulting
TrsLabs - Fintech Product & Business ConsultingTrsLabs - Fintech Product & Business Consulting
TrsLabs - Fintech Product & Business Consulting
Trs Labs
 
Special Meetup Edition - TDX Bengaluru Meetup #52.pptx
Special Meetup Edition - TDX Bengaluru Meetup #52.pptxSpecial Meetup Edition - TDX Bengaluru Meetup #52.pptx
Special Meetup Edition - TDX Bengaluru Meetup #52.pptx
shyamraj55
 
Noah Loul Shares 5 Steps to Implement AI Agents for Maximum Business Efficien...
Noah Loul Shares 5 Steps to Implement AI Agents for Maximum Business Efficien...Noah Loul Shares 5 Steps to Implement AI Agents for Maximum Business Efficien...
Noah Loul Shares 5 Steps to Implement AI Agents for Maximum Business Efficien...
Noah Loul
 
What is Model Context Protocol(MCP) - The new technology for communication bw...
What is Model Context Protocol(MCP) - The new technology for communication bw...What is Model Context Protocol(MCP) - The new technology for communication bw...
What is Model Context Protocol(MCP) - The new technology for communication bw...
Vishnu Singh Chundawat
 
Dev Dives: Automate and orchestrate your processes with UiPath Maestro
Dev Dives: Automate and orchestrate your processes with UiPath MaestroDev Dives: Automate and orchestrate your processes with UiPath Maestro
Dev Dives: Automate and orchestrate your processes with UiPath Maestro
UiPathCommunity
 
#StandardsGoals for 2025: Standards & certification roundup - Tech Forum 2025
#StandardsGoals for 2025: Standards & certification roundup - Tech Forum 2025#StandardsGoals for 2025: Standards & certification roundup - Tech Forum 2025
#StandardsGoals for 2025: Standards & certification roundup - Tech Forum 2025
BookNet Canada
 
Drupalcamp Finland – Measuring Front-end Energy Consumption
Drupalcamp Finland – Measuring Front-end Energy ConsumptionDrupalcamp Finland – Measuring Front-end Energy Consumption
Drupalcamp Finland – Measuring Front-end Energy Consumption
Exove
 
HCL Nomad Web – Best Practices und Verwaltung von Multiuser-Umgebungen
HCL Nomad Web – Best Practices und Verwaltung von Multiuser-UmgebungenHCL Nomad Web – Best Practices und Verwaltung von Multiuser-Umgebungen
HCL Nomad Web – Best Practices und Verwaltung von Multiuser-Umgebungen
panagenda
 
ThousandEyes Partner Innovation Updates for May 2025
ThousandEyes Partner Innovation Updates for May 2025ThousandEyes Partner Innovation Updates for May 2025
ThousandEyes Partner Innovation Updates for May 2025
ThousandEyes
 
HCL Nomad Web – Best Practices and Managing Multiuser Environments
HCL Nomad Web – Best Practices and Managing Multiuser EnvironmentsHCL Nomad Web – Best Practices and Managing Multiuser Environments
HCL Nomad Web – Best Practices and Managing Multiuser Environments
panagenda
 
2025-05-Q4-2024-Investor-Presentation.pptx
2025-05-Q4-2024-Investor-Presentation.pptx2025-05-Q4-2024-Investor-Presentation.pptx
2025-05-Q4-2024-Investor-Presentation.pptx
Samuele Fogagnolo
 
Big Data Analytics Quick Research Guide by Arthur Morgan
Big Data Analytics Quick Research Guide by Arthur MorganBig Data Analytics Quick Research Guide by Arthur Morgan
Big Data Analytics Quick Research Guide by Arthur Morgan
Arthur Morgan
 
Andrew Marnell: Transforming Business Strategy Through Data-Driven Insights
Andrew Marnell: Transforming Business Strategy Through Data-Driven InsightsAndrew Marnell: Transforming Business Strategy Through Data-Driven Insights
Andrew Marnell: Transforming Business Strategy Through Data-Driven Insights
Andrew Marnell
 
Cyber Awareness overview for 2025 month of security
Cyber Awareness overview for 2025 month of securityCyber Awareness overview for 2025 month of security
Cyber Awareness overview for 2025 month of security
riccardosl1
 
Build Your Own Copilot & Agents For Devs
Build Your Own Copilot & Agents For DevsBuild Your Own Copilot & Agents For Devs
Build Your Own Copilot & Agents For Devs
Brian McKeiver
 
Transcript: #StandardsGoals for 2025: Standards & certification roundup - Tec...
Transcript: #StandardsGoals for 2025: Standards & certification roundup - Tec...Transcript: #StandardsGoals for 2025: Standards & certification roundup - Tec...
Transcript: #StandardsGoals for 2025: Standards & certification roundup - Tec...
BookNet Canada
 
AI EngineHost Review: Revolutionary USA Datacenter-Based Hosting with NVIDIA ...
AI EngineHost Review: Revolutionary USA Datacenter-Based Hosting with NVIDIA ...AI EngineHost Review: Revolutionary USA Datacenter-Based Hosting with NVIDIA ...
AI EngineHost Review: Revolutionary USA Datacenter-Based Hosting with NVIDIA ...
SOFTTECHHUB
 

Python Code Camp for Professionals 1/4

  • 2. Ingredients • Python • Web server framework • Database • Love
  • 3. Bottle + GEvent • Async is cool • More efficientuse of CPU • Best for I/O-boundapplications
  • 4. Install Bottle + Gevent pip install gevent pip install bottle easy_install gevent easy_install bottle
  • 5. Hello World from gevent import monkey; monkey.patch_all() from bottle import run, route @route('/hello') def fxn(): return "Hello World!" run(server='gevent', host="localhost", port=8001, debug=True)
  • 7. Step Import gevent and bottle Magicallyreplace synchronouslibrarieswith async counterparts from gevent import monkey; monkey.patch_all() from bottle import run, route
  • 8. Step Assign theurl /hello to thefunctionbelow @route('/hello') Define a pythonfunction def fxn(): Return “HelloWorld!” to the browser return "Hello World!" Activate the gevent server, listen on port 8001 run(server='gevent', host="localhost", port=8001, debug=True)
  • 9. Accepting Inputs Via theurl http://www.gloopgroup.com/profile/paolo Via query string https://www.google.com.ph/?ion=1&q=gloopgroup Via POSTbody File upload to a website
  • 10. Inputs in Bottle Via theurl @route('/input1/<name>') def greet(name): return "Hello "+name Visit:localhost:8001/input1/paolo
  • 11. Inputs in Bottle Via query string @route('/sum') def sum(): total = 0 start = request.query.get("start") end = request.query.get("end") for i in range(start,end): total += i return "Sum of "+str(start) + " to " + str(end) + " = " + str(total) Visit: localhost:8001/sum?start=1&end=10
  • 12. Inputs in Bottle Via POST body @route('/login', method="POST") def login(): username = request.forms.get("username") password = request.forms.get("password") acceptedpasswords = ["gloopgroup", "devconph" , "adventuretime"] if password in acceptedpasswords: return "Welcome "+ username else: return "Unauthorized" Visit: localhost:8001/login using login page
  • 13. Activity 1 Create a calculatorapi: http://localhost:8001/operation/operand1/operand2 will return the value of operand1 <operation> operand2 Example: /subtraction/10/2 will output 8
  • 14. Common Return TYPES PlainText Similar to whatwe were doing earlier
  • 15. Common Return TYPES Binary Whenreturning fileslike images, video, audio, pdfs…
  • 16. Common Return TYPES JSON The common return type for APIs Example:FB API /{userid}/friends { "data": [ { "name": "Terence Pua", "id": "608407" }, { "name": "Gene Paul Quevedo", "id": "10153785024974240" }, { "name": "Jc Velasquez", "id": "722462218" }, { "name": "Jomel C. Imperio", "id": "779287017" } ], "summary": { "total_count": 770 } }
  • 17. Common Return TYPES HTML Returnweb pages with dynamic/static content <!DOCTYPE html> <html itemscope itemtype="http://schema.org/QAPage"> <head> <title>regex - Validate email address in JavaScript? - Stack Overflow</title> <link rel="shortcut icon" href="//cdn.sstatic.net/Sites/stackoverflow/img/favicon.ico?v=4f32ecc8f43d"> <link rel="apple-touch-icon image_src" href="//cdn.sstatic.net/Sites/stackoverflow/img/apple-touch-icon.png?v=c78bd457575a"> <link rel="search" type="application/opensearchdescription+xml" title="Stack Overflow" href="/opensearch.xml"> <meta name="twitter:card" content="summary"> <meta name="twitter:domain" content="stackoverflow.com"/> <meta property="og:type" content="website" /> <meta property="og:image" itemprop="image primaryImageOfPage" content="http://cdn.sstatic.net/Sites/stackoverflow/img/apple- [email protected]?v=73d79a89bded&a" /> <meta name="twitter:title" property="og:title" itemprop="title name" content="Validate email address in JavaScript?" /> <meta name="twitter:description" property="og:description" itemprop="description" content="How can an email address be validated in JavaScript?" /> <meta property="og:url" content="http://stackoverflow.com/questions/46155/validate-email-address-in-javascript"/> <link rel="canonical" href="http://stackoverflow.com/questions/46155/validate-email-address-in-javascript" />
  • 18. Returning JSON Object JSON Simplyreturn a dictionary or list @route("/json") def jason(): return {"lastname":"bourne", "alias":"David Webb"}
  • 19. Returning Static HTML HTML Use static_file from bottle @route("/loginpage") def loginpage(): return static_file("login.html", root=".")
  • 20. Testing the POST Handler Visit localhost:8081/loginpage Type your nameand use any of theseas passwordg gloopgroup, devconph, adventuretime Click submit
  • 21. The POST Request Cycle <form action="/login" method="POST"> Method dictates what kind of request happens when submitted Action tells the browser where to submit the request <input type="text" name="username"> Adds a text input that will be associated to the username field <input type="password" name="password"> Adds a password inputthat willbe associatedto the password field <input type="submit"> Adds a button that submits the form whenclicked
  • 22. Returning Dynamic HTML HTML Use a templatingengine: • Library thatcan substitutevariables intoa templatequickly and cleanly • Isolates thedesigner’s job of designing and thecoder’s job of coding
  • 23. Install Tenjin pip install tenjin easy_install tenjin
  • 24. Using Tenjin from gevent import monkey; monkey.patch_all() from bottle import run, route, request import tenjin from tenjin.helpers import * @route("/introduction/<name>/<age>/<work>") def template1(name, age, work): context = {"name":name, "age":age, "work":work} return engine.render("introduction.html", context); engine = tenjin.Engine(path=['.']) run(server='gevent', host="localhost", port=8001, debug=True)
  • 25. The template <!doctype html> <html lang="en"> <head> <title>Login</title> </head> <body> <h1>${name}</h1> <h2>Age:${age}<h2> <h2>Work:${work}<h2> </body> </html>
  • 26. Step from gevent import monkey; monkey.patch_all() from bottle import run, route, request import tenjin from tenjin.helpers import * Import alllibraries, including tenjin and all helper methods @route("/introduction/<name>/<age>/<work>") Define a route for the url, and define variables in it def template1(name, age, work): Declare a request handler and receive the variables from the url
  • 27. Step context = {"name":name, "age":age, "work":work} Define a context variable, which is a dictionary of values that will be substituted into the template return engine.render("introduction.html", context); Render the template called introduction.html using the context variable named context, and return it to the browser engine = tenjin.Engine(path=['.']) Instructs the templating engine to look for the templates in the directories listed in path
  • 28. Step (Inside the template) <!doctype html> <html lang="en"> <head> <title>Login</title> </head> <body> <h1>${name}</h1> <h2>Age:${age}<h2> <h2>Work:${work}<h2> </body> </html> { "name":"Paolo", "age":"30", "work":"Synergist" } +
  • 29. Displaying Lists @route("/spell/<word>") def template1(word): letters = list(word) context = {"letters":letters, "word":word} return engine.render("speller.html", context);
  • 30. Step @route("/spell/<word>") Define a route that accepts a variable assigned to word def speller(word): Define a handler that accepts avariable named word letters = list(word) Convert the text string into a listobject. From a string “word”, it becomes a list [“w”, “o”, “r”, “d”]
  • 31. Step context = {"letters":letters} Define a context variable, which contains the listof letters we just created return engine.render("speller.html", context); Render the template called speller.html using the context variable named context, and return it to the browser
  • 32. Step (Inside the template) <?py for letter in letters: ?> Loop on the elements of the list named letters <h3>${letter}</h3><br> Display the element letter along with the html <?py #endfor ?> Denote where the loop ends inthe template <a href="/greet/${word}">greet ${word}</a> Create a link that willcall the greet API we created earlier {"letters":["s", "u", "s", "h", "i"]}
  • 33. Highlighting Names @route("/profiles/<name>") def profile(name): users = [ {"name":"Em", "image":"http://goo.gl/aDxeu1", "age":30, "work":"Futurist"}, {"name":"Paolo", "image":"http://goo.gl/5k2oZr", "age":30, "work":"Synergist"} ] context = {"users":users, "name":name} return engine.render("profiles.html", context)
  • 34. Step users = [ {"name":"Em", "image":"http://goo.gl/aDxeu1", "age":30, "work":"Futurist"}, {"name":"Paolo", "image":"http://goo.gl/5k2oZr", "age":30, "work":"Synergist"} ] Define a list of dictionaries, with each dictionary objectcontaining information about a user. It contains information name,url of the image, age, and work context = {"users":users, "name":name} Define a conext containing the name to behighlighted, and the list of users return engine.render("profiles.html", context) Render the template named profiles.html with the context
  • 35. Step (Inside the template) <?py for user in users: ?> Loop on the elements of the list named users, each element in the listcan be referred to using the user variable <div style="height:100px;"> Create a div element in the html to contain one user element <img src="${user['image']}" style="float:left; height:100%;"/> Place an image in the html coming from the url defined in user[‘image’]
  • 36. Step (Inside the template) <?py if name==user["name"]: ?> Compare the current user’s name to the name entered in the url <strong>Name: ${user['name']}</strong> Thishappens when the above condition istrue, display the name asbold characters <?py else: ?> Add an else handler that executes if condition is not met
  • 37. Step (Inside the template) Name: ${user['name']} This happens when primary condition is not met, display the user’s name without any decorations <?py #endif ?> Denote where the if statement ends
  • 38. Make a Sushi Menu Create a menu using allthe sushiitems in the sushilistvariable Display the image and name of the sushi When the menu item is clicked, it should display another page containingthe name, image, price, and rating of the sushi(defined in the sushilistvariable) The most creative presentation of the menu wins aprize
  • 39. Activity 1 pip install gevent pip install bottle
  • 40. Cost per Mille = • Cost per 1000 impressions • Abuse of statistics • i.e. Magic • i.e. It sucks • Not based on empirical measured data ADVERTISING! Eyeballs cost
  • 41. How many are watching me right now? How many are paying attention? How many are interested? How many are still reading this part? How about now? Now?
  • 43. ROUTER ON PROMISCUOUS MODE DEVICEs SENDING PROBE REQUESTS
  • 49. snoop
  • 50. turn off your phones when going to the lagoon

Editor's Notes

  • #2: This is our current project onewatt. It’s a device that can save you up to 40% in your electricity bills by utilizing fluctuations in electricicty prices in WESM throughout the day. How?
  • #3: I wont be talking about OneWatt. Since, apparently, Wilson deemed this thing not too thingie enough for the internet of things. So I’m going to talk about something more thingie…
  • #4: I wont be talking about OneWatt. Since, apparently, Wilson deemed this thing not too thingie enough for the internet of things. So I’m going to talk about something more thingie…
  • #5: I did this by exploiting one of the thingiest thinies right now, something that everyone here has on them most fo the time. Your mobile devices. Assuming that an average person has at least 1 devic eon them, I was able to get how many people walked by the screen, how many stayed for at least 2 secs, and how many people finished the ad.
  • #6: I did this by exploiting one of the thingiest thinies right now, something that everyone here has on them most fo the time. Your mobile devices. Assuming that an average person has at least 1 devic eon them, I was able to get how many people walked by the screen, how many stayed for at least 2 secs, and how many people finished the ad.
  • #8: I wont be talking about OneWatt. Since, apparently, Wilson deemed this thing not too thingie enough for the internet of things. So I’m going to talk about something more thingie…
  • #9: I wont be talking about OneWatt. Since, apparently, Wilson deemed this thing not too thingie enough for the internet of things. So I’m going to talk about something more thingie…
  • #10: I wont be talking about OneWatt. Since, apparently, Wilson deemed this thing not too thingie enough for the internet of things. So I’m going to talk about something more thingie…
  • #11: I wont be talking about OneWatt. Since, apparently, Wilson deemed this thing not too thingie enough for the internet of things. So I’m going to talk about something more thingie…
  • #12: I wont be talking about OneWatt. Since, apparently, Wilson deemed this thing not too thingie enough for the internet of things. So I’m going to talk about something more thingie…
  • #13: I wont be talking about OneWatt. Since, apparently, Wilson deemed this thing not too thingie enough for the internet of things. So I’m going to talk about something more thingie…
  • #14: I did this by exploiting one of the thingiest thinies right now, something that everyone here has on them most fo the time. Your mobile devices. Assuming that an average person has at least 1 devic eon them, I was able to get how many people walked by the screen, how many stayed for at least 2 secs, and how many people finished the ad.
  • #15: I wont be talking about OneWatt. Since, apparently, Wilson deemed this thing not too thingie enough for the internet of things. So I’m going to talk about something more thingie…
  • #16: I wont be talking about OneWatt. Since, apparently, Wilson deemed this thing not too thingie enough for the internet of things. So I’m going to talk about something more thingie…
  • #17: I wont be talking about OneWatt. Since, apparently, Wilson deemed this thing not too thingie enough for the internet of things. So I’m going to talk about something more thingie…
  • #18: I wont be talking about OneWatt. Since, apparently, Wilson deemed this thing not too thingie enough for the internet of things. So I’m going to talk about something more thingie…
  • #19: I wont be talking about OneWatt. Since, apparently, Wilson deemed this thing not too thingie enough for the internet of things. So I’m going to talk about something more thingie…
  • #20: I wont be talking about OneWatt. Since, apparently, Wilson deemed this thing not too thingie enough for the internet of things. So I’m going to talk about something more thingie…
  • #21: I wont be talking about OneWatt. Since, apparently, Wilson deemed this thing not too thingie enough for the internet of things. So I’m going to talk about something more thingie…
  • #22: I wont be talking about OneWatt. Since, apparently, Wilson deemed this thing not too thingie enough for the internet of things. So I’m going to talk about something more thingie…
  • #23: I wont be talking about OneWatt. Since, apparently, Wilson deemed this thing not too thingie enough for the internet of things. So I’m going to talk about something more thingie…
  • #24: I did this by exploiting one of the thingiest thinies right now, something that everyone here has on them most fo the time. Your mobile devices. Assuming that an average person has at least 1 devic eon them, I was able to get how many people walked by the screen, how many stayed for at least 2 secs, and how many people finished the ad.
  • #25: I did this by exploiting one of the thingiest thinies right now, something that everyone here has on them most fo the time. Your mobile devices. Assuming that an average person has at least 1 devic eon them, I was able to get how many people walked by the screen, how many stayed for at least 2 secs, and how many people finished the ad.
  • #26: I did this by exploiting one of the thingiest thinies right now, something that everyone here has on them most fo the time. Your mobile devices. Assuming that an average person has at least 1 devic eon them, I was able to get how many people walked by the screen, how many stayed for at least 2 secs, and how many people finished the ad.
  • #27: I wont be talking about OneWatt. Since, apparently, Wilson deemed this thing not too thingie enough for the internet of things. So I’m going to talk about something more thingie…
  • #28: I wont be talking about OneWatt. Since, apparently, Wilson deemed this thing not too thingie enough for the internet of things. So I’m going to talk about something more thingie…
  • #29: I wont be talking about OneWatt. Since, apparently, Wilson deemed this thing not too thingie enough for the internet of things. So I’m going to talk about something more thingie…
  • #30: I wont be talking about OneWatt. Since, apparently, Wilson deemed this thing not too thingie enough for the internet of things. So I’m going to talk about something more thingie…
  • #31: I wont be talking about OneWatt. Since, apparently, Wilson deemed this thing not too thingie enough for the internet of things. So I’m going to talk about something more thingie…
  • #32: I wont be talking about OneWatt. Since, apparently, Wilson deemed this thing not too thingie enough for the internet of things. So I’m going to talk about something more thingie…
  • #33: I wont be talking about OneWatt. Since, apparently, Wilson deemed this thing not too thingie enough for the internet of things. So I’m going to talk about something more thingie…
  • #34: I wont be talking about OneWatt. Since, apparently, Wilson deemed this thing not too thingie enough for the internet of things. So I’m going to talk about something more thingie…
  • #35: I wont be talking about OneWatt. Since, apparently, Wilson deemed this thing not too thingie enough for the internet of things. So I’m going to talk about something more thingie…
  • #36: I wont be talking about OneWatt. Since, apparently, Wilson deemed this thing not too thingie enough for the internet of things. So I’m going to talk about something more thingie…
  • #37: I wont be talking about OneWatt. Since, apparently, Wilson deemed this thing not too thingie enough for the internet of things. So I’m going to talk about something more thingie…
  • #38: I wont be talking about OneWatt. Since, apparently, Wilson deemed this thing not too thingie enough for the internet of things. So I’m going to talk about something more thingie…
  • #39: I did this by exploiting one of the thingiest thinies right now, something that everyone here has on them most fo the time. Your mobile devices. Assuming that an average person has at least 1 devic eon them, I was able to get how many people walked by the screen, how many stayed for at least 2 secs, and how many people finished the ad.
  • #40: I did this by exploiting one of the thingiest thinies right now, something that everyone here has on them most fo the time. Your mobile devices. Assuming that an average person has at least 1 devic eon them, I was able to get how many people walked by the screen, how many stayed for at least 2 secs, and how many people finished the ad.
  • #41: One of the key metrics used in advertising is the number of eyeballs gained by an ad. Makes sense, since advertisers are paying to have their ads seen by the most amount of people. The problem with this though is that this number, or Cost per Mille, is an abuse of statistics, it is not based on a solid methodology. So back then we did this media wall project in Shanghai. we wanted to prove how many people saw the ad, and how long people were looking at it. So we devised a way to have more empirical data.
  • #42: As of now, I can empirically estimate about ___________ watching me right now.   (turn on device and get count)
  • #43: The setup is actually quite simple. You can even do it with a router, but for this purpose, I used a pi, connected to a wifi dongle, and this cute little screen i salvaged from an old tv, all powered by a power bank. Very mcgyvery.
  • #44: This wifi transmitter is set to promiscuous mode, para syang carinderia na bukas sa lahat ng gutong kumain, actually worse, bukas kahit sa mga walang planong kumain. Using this, I am able to sniff all the traffic being trasmitted by all the dvices, specifically probe requests, within a certain range, (with this range varying based on the yyy used).
  • #45: The CPU, running python, gets the output of tcpdump, mining all the sniffed mac addresses and adding timestamps to each record withing the vicinity, without them installing anything on their device or being aware. So right now I am getting all the mad accdresses of the devices of this group right here, since they are withing x meters form me, which I can now use to check for uniqueness, use for idnetification or use in whatever evil scheme I plan. Sounds excting diba? Borderline snooping.
  • #46: We ran this on 2 pilot sites, one in Zhngshan park, and the other in Lujiazhui station. Using my setup, on the average, there were 23000 people who pass by our screens everyday, 36% of which stopped and watched for at least 2 secs, and around 10% stayed finished the 15 second ad.
  • #47: So, especially for the group here <referto prev group>, so what if you got our mac addrsses, that doesn’t sound too bad, are there other possible application of this?
  • #48: I have used this device in stores to measure foot traffic. I can identify how a customer moves between shelves, and identifying which items attract the most views. Which is important data for a retailer or advertiser.
  • #49: You can also use this as a replacemnt for gps in geofencing. By attenuating the broadcast range to a specific area. You can then identify new and returning customers to your shop, and instruct your staff to be more accommodating to new customers going in.
  • #50: And the most fun thing to do with this s probably just snoop. Imagine if we install one of these in each classroom. Using simple data such as class schedules, we can then relate a mac address to a specific student. Imagine then if we leave this device in the lagoon area. We will now have a list of people visiting that spot at say 10pm onwards. Who is meeting who, who is coming in in groups of 2 or even people coming in groups of 3 or more.
  • #51: So in summary, turn off your phones when going to the lagoon.