forked from dunossauro/live-de-python
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathparte_2.py
More file actions
35 lines (27 loc) · 786 Bytes
/
Copy pathparte_2.py
File metadata and controls
35 lines (27 loc) · 786 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
"""
Exemplo usando um formulário WEB.
Objetivo: entender 'request'
"""
from bottle import route, run, request
@route('/', method='GET')
def index_get():
"""Exemplo do metodo get expondo os forms."""
return '''
<form action="/" method="post">
Username: <input name="username" type="text" />
Password: <input name="password" type="password" />
<input value="Login" type="submit" />
</form>
'''
@route('/', method='POST')
def index_post():
"""Exemplo do metodo POST recebendo os dados do form."""
username = request.forms.get('username')
password = request.forms.get('password')
return """
<h1>Suas informações</h1>
</br>
<h4>{}</h4>
<h4>{}</h4>
""".format(username, password)
run(port=8080)