This is a Flask app for searching in Wikipedia.
It looks as a simple web page with a textbox and a “search” button. Hitting “search” searches a term (or phrase) in Wikipedia using its API.
- If the result is found it displays a short description and an image (optionally).
- If multiple results found, shows “It may refer to:” and list of links. Links are clickable and search more precise term.
- Else, it shows “term not found”.
The app is written in Python 3.7.4, so you need a proper version be installed. It depends on following libs, so you also need:
flask
requests
re
Just hit the run.py
in the main folder for server to start.
The app be accessed on http://localhost:5000
.
Input the term or phrase into the textbox and hit the "Search" button.
The app connects to Wikipedia API and returns a simple web page containing data depending on response type.
If the ID for the response page is '-1'
, there is no results for the requested phrase.
An empty page be returned.
If the response page has embedded key 'disambiguation'
, the list of referred titles be returned.
Being clicked it returns a rendered page depends on type of API response (recursively).
A page containing a list of related clickable titles be returned.
If the response page has a proper ID and it is not a 'disambiguation' page, treats the page like an article. In this case the article description and image be extracted if it is possible. In case of description absence the first summary sentence be used instead. A page containing an image (optionally) and a short description be returned.