Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
S
slide-index
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Welter, Felix
slide-index
Commits
ee1ac200
Commit
ee1ac200
authored
4 years ago
by
felixwelter
Browse files
Options
Downloads
Patches
Plain Diff
Update to new request format
parent
394e261b
No related branches found
No related tags found
No related merge requests found
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
app.py
+12
-6
12 additions, 6 deletions
app.py
templates/index.html
+35
-12
35 additions, 12 deletions
templates/index.html
with
47 additions
and
18 deletions
app.py
+
12
−
6
View file @
ee1ac200
...
...
@@ -3,7 +3,7 @@ import sys
from
pathlib
import
Path
import
pdfplumber
from
flask
import
Flask
,
render_template
,
request
,
redirect
,
send_file
from
flask
import
Flask
,
render_template
,
request
,
redirect
,
send_file
,
jsonify
from
werkzeug.utils
import
secure_filename
from
title_focus_search_index
import
TitleFocusSearchIndex
...
...
@@ -47,16 +47,22 @@ def upload():
return
redirect
(
'
/
'
)
@app.route
(
"
/search
"
)
@app.route
(
"
/search
"
,
methods
=
[
'
POST
'
]
)
def
query
():
try
:
index
=
Index
()
query
=
request
.
args
.
get
(
"
term
"
)
query
=
request
.
form
.
get
(
"
term
"
)
context
=
request
.
form
.
get
(
"
context
"
)
# TODO: Use context to find better results
result
=
index
.
search
(
query
)
img_name
=
result
[
"
path
"
][
7
:]
+
"
_
"
+
str
(
result
[
"
page
"
])
+
"
.jpg
"
return
"
slide/
"
+
img_name
except
:
return
str
(
sys
.
exc_info
()[
0
]).
replace
(
"
<
"
,
"
-
"
).
replace
(
"
>
"
,
"
-
"
)
return
jsonify
({
"
type
"
:
"
image
"
,
"
path
"
:
"
slide/
"
+
img_name
})
except
IndexError
:
return
jsonify
({
"
type
"
:
"
miss
"
})
@app.route
(
"
/slide/<img_name>
"
)
...
...
This diff is collapsed.
Click to expand it.
templates/index.html
+
35
−
12
View file @
ee1ac200
...
...
@@ -8,14 +8,37 @@
<input
type=
"file"
name=
"file"
>
<input
type=
"submit"
value=
"Upload"
>
</form>
{% for item in ll %}
<ul>
{% for item in ll %}
<ul>
<li>
{{ item }}
</li>
</ul>
{% endfor %}
<h1>
Query
</h1>
<form
action=
"search"
method=
"get"
>
<input
name=
"term"
>
<form
action=
"search"
method=
"post"
>
<input
name=
"term"
placeholder=
"term"
><br>
<input
name=
"context"
placeholder=
"context"
><br>
<input
type=
"submit"
value=
"Query"
>
</form>
<button
onclick=
"execute();"
>
Execute
</button>
<script>
function
execute
()
{
var
http
=
new
XMLHttpRequest
();
var
url
=
'
/search
'
;
var
params
=
'
term=Freedom&Concept Evaluation
'
http
.
open
(
'
POST
'
,
url
,
true
);
http
.
setRequestHeader
(
'
Content-type
'
,
'
application/x-www-form-urlencoded
'
);
http
.
onreadystatechange
=
function
()
{
if
(
http
.
readyState
==
4
&&
http
.
status
==
200
)
{
console
.
log
(
http
.
responseText
);
console
.
log
(
JSON
.
parse
(
http
.
responseText
));
}
}
http
.
send
(
params
);
}
</script>
</body>
</html>
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment