-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtext.py
97 lines (83 loc) · 2.53 KB
/
text.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
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
# from flask import Flask
# app = Flask(__name__)
# @app.route('/')
# def hello_world():
# return 'Hello, World!fdjkdhh'
# if __name__ == "__main__":
# app.run(host='0.0.0.0')
# Answer to a question on Flask mailing list
# http://librelist.com/browser//flask/2012/6/30/using-ajax-with-flask/
# NOTE: *REALLY* don't do the thing with putting the HTML in a global
# variable like I have, I just wanted to keep everything in one
# file for the sake of completeness of answer.
# It's generally a very bad way to do things :)
#
from flask import (Flask, request, jsonify)
from flask import render_template , request
##brk
print("hi br")
app = Flask(__name__)
# html_page = """<!DOCTYPE HTML>
# <html>
# <head>
# <title>Rough AJAX Test</title>
# <script>
# function loadXMLDoc()
# {
# var req = new XMLHttpRequest()
# req.onreadystatechange = function()
# {
# if (req.readyState == 4)
# {
# if (req.status != 200)
# {
# //error handling code here
# }
# else
# {
# var response = JSON.parse(req.responseText)
# document.getElementById('myDiv').innerHTML = response.username
# }
# }
# }
# req.open('POST', '/ajax')
# req.setRequestHeader("Content-type", "application/x-www-form-urlencoded")
# var un = document.getElementById('scname').value
# var sec = document.getElementById('secret').value
# var postVars = 'username='+un+'&secret='+sec
# req.send(postVars)
# return false
# }
# </script>
# </head>
# <body>
# <h1>Flask AJAX Test</h1>
# <form action="" method="POST">
# <input type="text" name="scname" id="scname">
# <input type="hidden" name="secret" id="secret" value="shhh">
# <input type="button" value="Submit" onclick="return loadXMLDoc()">
# </form>
# <div id="myDiv"></div>
# </body>
# </html>"""
@app.route('/')
def index():
# return html_page
return render_template('index.html')
@app.route('/search', methods = ['GET','POST'])
def search():
q = request.form['query']
# username = request.args.post('username')
l=[]
l.append("static/lec.webm")
l.append("56.445")
ll=[]
ll.append(l)
l=[]
l.append("static/lec1.webm")
l.append("43.785")
ll.append(l)
# print(jsonify(username=l))
return jsonify(ans=ll,result=q)
if __name__ == "__main__":
app.run(debug = True)