Introdução a Desenvolvimento Web, passando por todas as etapas do desenvolvimento, como noções de Servidores Web, criando o seu próprio servidor web simples em Python e entendendo noções de HTML, CSS e Javascript.
3. Volta no tempo
Comecei a programar em meados de 2002~2003.
Pude trabalhar até agora com:
XHTML, CSS, Javascript, Python, PHP, C/C++,
Coldfusion, Java, Actionscript, Melscript, XML,
Perl, Ruby, Prolog, Haskell, Bash. (17+)
3
4. Pacote mínimo para desenvolvimento web
Linguagens de Marcação:
HTML, xHTML, HTML 5
Linguagens para folha de estilo:
CSS
Linguagens client-side:
Javascript, Dart?
Linguagens server-side:
Python, PHP, Java, Perl, Ruby, Haskell, Lua.
4
8. Servidor Web Simples em Python
from os import curdir as pwd if __name__ == '__main__':
from os import sep as separador try:
from BaseHTTPServer import BaseHTTPRequestHandler server = HTTPServer(('', 7777), MeuHandler)
from BaseHTTPServer import HTTPServer server.serve_forever()
except KeyboardInterrupt:
class MeuHandler(BaseHTTPRequestHandler): server.socket.close()
def do_GET(self):
try:
if self.path.endswith(".html"): Executanto:
f = open(pwd + separador + self.path)
self.send_response(200) $ python servidor.py
self.send_header('Content-type', 'text/html')
self.end_headers() Visualizando:
self.wfile.write(f.read())
f.close() Http://127.0.0.1:7777/arquivo.html
except IOError:
self.send_error(404,'File Not Found: %s' % self.path)
def do_POST(self):
self.wfile.write("<p>POST</p>");
8
(continua na outra coluna)
9. Servidores Web (Ready for Action)
Strong focus on high concurrency, performance and low
memory usage. (sic)
Rápido, Configurável, LoadBalancer, Estável
Although the main design goal of Apache is not to be the
"fastest" web server. (sic)
Configurável, Padrão de Mercado
9
11. (Outros) Servidores Web (Ready for Action)
Maintainer: Facebook
Além de ser um servidor de alta performance
também é um Framework robusto.
I/O Não Bloqueante
gevent.org Baseado em corotinas (Trocas de Contexto)
Fast Asynchronous Python Web Server - FAPWS
Usado no eBay.
100 milhões (simples) requisições por dia em
2 servidores 4-core.
11
13. Primeiros Passos com HTML 5
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>Título do Site</title>
</head>
<body>
<p>Conteúdo de um paragrafo.</p>
</body>
</html>
13
14. Primeiros Passos com HTML 5
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>Titulo do Site</title>
</head>
<body>
<p>Conteúdo de um paragrafo.</p>
</body>
</html>
14
15. Primeiros Passos com HTML 5
<!DOCTYPE html>
<html>
<head>...</head> (igual anteriormente)
<body>
<!-- Comentário -->
<form action="arquivo.py" method="POST">
<label for="nome">Digite seu nome:</label>
<input type="text" name="nome" id="nome" />
<input type="submit" value="Enviar" />
</form>
</body>
</html>
15
16. Primeiros Passos com HTML 5
<!DOCTYPE html>
<html>
<head>...</head> (igual anteriormente)
<body>
<!-- Comentário -->
<form action="arquivo.py" method="POST">
<label for="nome">Digite seu nome:</label>
<input type="text" name="nome" id="nome" />
<input type="submit" value="Enviar" />
</form>
</body>
</html>
16
17. Primeiros Passos com HTML 5
<!DOCTYPE html>
<html>
<head>...</head> (igual anteriormente)
<body>
<img src=”luz.jpg” border=”0” />
</body>
</html>
17
18. Primeiros Passos com HTML 5
<!DOCTYPE html>
<html>
<head>...</head> (igual anteriormente)
<body>
<img src=”luz.jpg” border=”0” />
</body>
</html>
18
19. Primeiros Passos com HTML 5
<!DOCTYPE html>
<html>
<head>...</head> (igual anteriormente)
<body>
<select name="genero">
<option value="masculino">Masculino</option>
<option value="feminino">Feminino</option>
</select>
</body>
</html>
19
20. Primeiros Passos com HTML 5
<!DOCTYPE html>
<html>
<head>...</head> (igual anteriormente)
<body>
<select name="genero">
<option value="masculino">Masculino</option>
<option value="feminino">Feminino</option>
</select>
</body>
</html>
20