-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapp.py
More file actions
25 lines (20 loc) · 773 Bytes
/
app.py
File metadata and controls
25 lines (20 loc) · 773 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
from bottle import route, run, response, template
countries = [
{"name": "Algeria", "capital": "Algiers", "population": 43851044},
{"name": "Egypt", "capital": "Cairo", "population": 104124440},
{"name": "Morocco", "capital": "Rabat", "population": 36910560},
{"name": "Tunisia", "capital": "Tunis", "population": 11818619},
{"name": "Libya", "capital": "Tripoli", "population": 6871292}
]
@route('/')
def home():
return template('home', countries=countries)
@route('/hello/<name>')
def hello(name):
return f"Hello, {name}! youcef are amazing!"
@route('/countries')
def get_countries():
response.content_type = 'application/json'
return {"countries": countries}
if __name__ == "__main__":
run(host='localhost', port=8080, debug=True, reloader=True)