-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapp.py
More file actions
28 lines (22 loc) · 683 Bytes
/
app.py
File metadata and controls
28 lines (22 loc) · 683 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
from markupsafe import escape
from flask import Flask, abort
app = Flask(__name__)
@app.route('/')
def hello():
return '<h1>Ciao, Mondo!</h1>'
@app.route('/about/')
def about():
return '<h3>Questa è una applicazione python - flask.</h3>'
@app.route('/capitalize/<word>/')
def capitalize(word):
return '<h1>{}</h1>'.format(escape(word.capitalize()))
@app.route('/add/<int:n1>/<int:n2>/')
def add(n1, n2):
return '<h1>{}</h1>'.format(n1 + n2)
@app.route('/users/<int:user_id>/')
def greet_user(user_id):
users = ['Bob', 'Jane', 'Adam']
try:
return '<h2>Hi {}</h2>'.format(users[user_id])
except IndexError:
abort(404)