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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
| from flask import Flask, render_template, request
from flask_assets import Environment, Bundle
app = Flask(__name__)
assets = Environment(app)
css = Bundle("src/main.css", output="dist/main.css")
js = Bundle("src/*.js", output="dist/main.js")
assets.register("css", css)
assets.register("js", js)
css.build()
js.build()
class User:
id = 0
def __init__(self, fname, lname, email ):
User.id += 1
self.id = User.id
self.fname = fname
self.lname = lname
self.email = email
def search( self, word ):
if (word is None):
return False
all = self.fname + self.lname + self.email
return word.lower() in all.lower()
users = [
User("abe", "vida", "[email protected]"),
User("betty", "b", "[email protected]"),
User("joe", "robinson", "[email protected]"),
User("Luis", "Cortes", "[email protected]"),
User("marty", "hinkle", "[email protected]"),
User("matthew", "robinson", "[email protected]"),
User("collin", "western", "[email protected]"),
User("marty", "hinkle II", "[email protected]"),
User("joe", "robinson", "[email protected]"),
User("juan", "vida", "[email protected]"),
User("marty", "hinkle III", "[email protected]"),
User("zoe", "omega", "[email protected]")
]
@app.route("/")
def index():
return render_template("index.html")
@app.route("/search", methods=["POST"])
def search():
word = request.form.get("search")
if (word is None or word == ""):
return render_template("search.html", users=[])
else:
return render_template("search.html", users=filter(lambda u: u.search(word), users))
if __name__ == "__main__":
app.run(debug=True)
|