Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
A
AiWebProject1
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Simon Rebers
AiWebProject1
Commits
ba1b4e00
Commit
ba1b4e00
authored
1 year ago
by
srebers
Browse files
Options
Downloads
Patches
Plain Diff
First search engine prototype is running
parent
13590527
No related branches found
No related tags found
No related merge requests found
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
crawler.py
+0
-2
0 additions, 2 deletions
crawler.py
myapp.py
+25
-8
25 additions, 8 deletions
myapp.py
templates/result.html
+16
-0
16 additions, 0 deletions
templates/result.html
templates/start.html
+12
-0
12 additions, 0 deletions
templates/start.html
with
53 additions
and
10 deletions
crawler.py
+
0
−
2
View file @
ba1b4e00
...
...
@@ -44,6 +44,4 @@ while not queue.empty():
queue
.
put
(
href
)
visited_list
.
add
(
href
)
#TODO: Analyze it and update the index
print
(
visited_list
)
This diff is collapsed.
Click to expand it.
myapp.py
+
25
−
8
View file @
ba1b4e00
...
...
@@ -4,13 +4,30 @@ import indexing
# Retrieving data
from
whoosh.qparser
import
QueryParser
ix
=
indexing
.
get_index
()
from
flask
import
Flask
,
request
,
render_template
with
ix
.
searcher
()
as
searcher
:
# find entries with the words 'first' AND 'last'
query
=
QueryParser
(
"
content
"
,
ix
.
schema
).
parse
(
input
(
"
search for something:
\n
"
))
results
=
searcher
.
search
(
query
)
def
search_index
(
keyword
:
str
):
ix
=
indexing
.
get_index
()
with
ix
.
searcher
()
as
searcher
:
# find entries with the words 'first' AND 'last'
query
=
QueryParser
(
"
content
"
,
ix
.
schema
).
parse
(
keyword
)
results
=
searcher
.
search
(
query
)
# print all results
for
r
in
results
:
print
(
r
)
\ No newline at end of file
# print all results
result_links
=
[]
for
r
in
results
:
result_links
.
append
(
r
.
fields
()[
"
url
"
])
return
result_links
search_index
(
"
platypus
"
)
app
=
Flask
(
__name__
)
@app.route
(
"
/
"
)
def
start
():
return
render_template
(
"
start.html
"
,
title
=
"
start
"
)
@app.route
(
"
/result
"
)
def
reverse
():
rev
=
request
.
args
.
get
(
'
rev
'
)
return
render_template
(
"
result.html
"
,
title
=
"
search for:
"
+
rev
,
result
=
search_index
(
rev
))
\ No newline at end of file
This diff is collapsed.
Click to expand it.
templates/result.html
0 → 100644
+
16
−
0
View file @
ba1b4e00
<!DOCTYPE html>
<html>
<head>
<title>
{{ title }}
</title>
</head>
<body>
<h1>
Results:
</h1>
<ul>
{% for item in result %}
<li>
<a
href=
{{
item
}}
>
{{ item }}
</a>
</li>
{% endfor %}
</ul>
</body>
</html>
\ No newline at end of file
This diff is collapsed.
Click to expand it.
templates/start.html
0 → 100644
+
12
−
0
View file @
ba1b4e00
<!DOCTYPE html>
<html>
<head>
<title>
{{ title }}
</title>
</head>
<body>
<h1>
Hello World
</h1>
<form
action=
"result"
method=
"GET"
>
<input
type=
"text"
name=
'rev'
>
</form>
</body>
</html>
\ No newline at end of file
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