Nesta palestra irei falar da experiência que tive no desenvolvimento do Soar(www.soarmp3.com.br) usando o micro-framework Flask, e o servidor Cloud OpenShift(openshift.redhat.com) da Red hat. Vale ressaltar que a aplicação foi ao ar em apenas um dia. :D
4. Porque Flask?
• Fácil • Rápido
• Simples
from flask import Flask
app = Flask(__name__)
@app.route("/")
def hello():
return "Hello World!"
if __name__ == "__main__":
app.run(debug = True)
5. Eventlet
• Biblioteca concorrente de rede;
• Similar a threads, mas sem blocking I/O;
6. Eventlet
urls = ["http://www.google.com/intl/en_ALL/images/logo.gif",
"https://wiki.secondlife.com/w/images/secondlife.jpg",
"http://us.i1.yimg.com/us.yimg.com/i/ww/beta/y3.gif"]
import eventlet
from eventlet.green import urllib2
def fetch(url):
return urllib2.urlopen(url).read()
pool = eventlet.GreenPool() //Cria um vetor de threads
for body in pool.imap(fetch, urls): //Mapea urls para a função fetch
print "got body", len(body)
7. OpenShift – quota free
• 3 gear(512MB) e escaláveis;
• 1 GB por gear;
• Node.js, Ruby, Python, PHP, Perl, and Java;
• Deploy usando o git;
• Sem restrições de banda.
8. Links
• Eventlet: http://eventlet.net/
• Flask: http://flask.pocoo.org/
• OpenShift:
o https://openshift.redhat.com/
o https://openshift.redhat.com/community/get-started