-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathserver.py
executable file
·35 lines (28 loc) · 1 KB
/
server.py
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
from bottle import route, run
import random
names = ["John", "Mark", "Bruce", "Jason", "Roy", "Ryan", "David", "Charles", "George", "Tomas", "Jeniffer", "Lisa",
"Zoe", "Peter", "Leon", "Paul", "Frank"]
surnames = ["Johnson", "Jackson", "McBride", "Larson", "Phoenix", "Galaman", "Calahan", "Smith", "Jackman",
"Underwood", "Stark", "Parker", "Forcyde"]
roles = {
"admin": 2,
"reporter": 1,
"basic": 0
}
def generate_contacts(number_of_contacts=8):
contacts = []
for i in range(1, number_of_contacts):
name = names[random.randint(0, len(names) - 1)]
surname = surnames[random.randint(0, len(surnames) - 1)]
role = roles[roles.keys()[random.randint(0, len(roles) - 1)]]
contact = {
"name": name,
"surname": surname,
"role": role
}
contacts.append(contact)
return contacts
@route('/contacts')
def contacts():
return {"response": generate_contacts()}
run(host='localhost', port=8080, debug=True)