-
Notifications
You must be signed in to change notification settings - Fork 10
/
Copy pathapp.py
34 lines (26 loc) · 802 Bytes
/
app.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
"""
AJAX License example
"""
from flask import Flask, request
app = Flask(__name__)
@app.route("/check_license", methods=["POST"])
def check_license():
VALID_LICENSES = {
"Smith": "ABC-123",
"John Smith": "CDE-999",
"Mary": "PPP-111"
}
name = request.form.get("name", None)
license = request.form.get("license", None)
# check if name and license match
if name and license:
if VALID_LICENSES.get(name, None) == license:
return "<img src='/static/images/yes.png' /> Valid license key"
else:
return "<img src='/static/images/no.png' /> Invalid license key for {}".format(name)
return ""
@app.route("/")
def index():
return app.send_static_file("license.html")
if __name__ == "__main__":
app.run()