-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathflaskapp.py
66 lines (54 loc) · 1.4 KB
/
flaskapp.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
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
from flask import Flask
from string import Template
app = Flask(__name__)
HTML_TEMPLATE = Template("""
<!DOCTYPE html>
<html>
<img src="./media/${id}.jpg">
</html>
""")
@app.route('/')
@app.route('/index')
def index():
return """
<!DOCTYPE html>
<html>
<input type="text" id="txt"><br>
<button id="myButton" class="float-left submit-button">Submit</button>
<script type="text/javascript">
document.getElementById("myButton").onclick=function(){
var txtVal = document.getElementById("txt").value;
if (txtVal=="page2"){
window.location.href = "/page2";
}
if (txtVal=="Kelly"){
window.location.href = "https://bing.com";
}
}
</script>
</html>
"""
@app.route('/page2')
def image_page():
return"""
<!DOCTYPE html>
<html>
<head>
<title>Page Title</title>
</head>
<body>
<img src="./media/1111.jpg" alt="Family shoppers">
<script type="text/javascript">
setTimeout(function(){
window.location.href = "/index";
}, 5000)
</script>
</body>
</html>
"""
if __name__ == '__main__':
app.run(debug=True, use_reloader=True)
# <form method="GET" action="my_result.php">
# <input type="text" name="customer_id">
# <input type="submit">
# </form>