The Wayback Machine - https://web.archive.org/web/20240927183540/https://www.geeksforgeeks.org/wikipedia-search-app-using-flask-framework-python/
Open In App

Wikipedia search app using Flask Framework – Python

Last Updated : 14 May, 2024
Summarize
Comments
Improve
Suggest changes
Like Article
Like
Save
Share
Report
News Follow

Flask is a micro web framework written in Python. It is classified as a micro-framework because it does not require particular tools or libraries. Flask is a lightweight WSGI web application framework. It is designed to make getting started quick and easy, with the ability to scale up to complex applications.

Installation:

1) In order to create the flask app we have to first install the flask.

pip install flask

2) In order to extract the data from Wikipedia, we must first install the Python Wikipedia library.

pip install wikipedia

Create a flask app:

3) Create a file and name it as app.py

4) Create the templates folder to store all the html files.

Folder structure:

How to create wikipedia search app using Flask Framework?

Now, let’s start coding the application

Create the file  – app.py

Python3




# import necessary libraries
from flask import Flask, request, render_template
import wikipedia
  
app = Flask(__name__)
  
# create HOME View
@app.route("/", methods=["POST", "GET"])
def home():
    if request.method == "GET":
        return render_template("index.html")
    else:
        search = request.form["search"]
  
        # Fetch data from wikipedia
        result = wikipedia.summary(search, sentences=2)
        return f"<h1>{result}</h1>"
  
  
if __name__ == '__main__':
    app.run(debug=True)


Create a file index.html that will be used by flask – 

HTML




<!DOCTYPE html>
<html>
<head>
    <title>Wikipedia Search</title>
</head>
<body>
    <form method="post">
    <input type="text" name="search">
    <br>
    <button type="submit">Search</button>
    </form>
</body>
</html>


Output:

If we search INDIA in this input tag then the output is:



Previous Article
Next Article

Similar Reads

Wikipedia search app Project using Django
Django is a high-level Python based Web Framework that allows rapid development and clean, pragmatic design. It is also called batteries included framework because Django provides built-in features for everything including Django Admin Interface, default database – SQLlite3, etc. Today we will create joke app in django. In this article we will make
2 min read
Voice search Wikipedia using Python
Every day, we visit so many applications, be it messaging platforms like Messenger, Telegram or ordering products on Amazon, Flipkart, or knowing about weather and the list can go on. And we see that these websites have their own software program for initiating conversations with human beings using rules or artificial intelligence. Users interact w
5 min read
Documenting Flask Endpoint using Flask-Autodoc
Documentation of endpoints is an essential task in web development and being able to apply it in different frameworks is always a utility. This article discusses how endpoints in Flask can be decorated to generate good documentation of them using the Flask-Autodoc module. This module provides the following features - Helps to document endpoints of
4 min read
Minify HTML in Flask using Flask-Minify
Flask offers HTML rendering as output, it is usually desired that the output HTML should be concise and it serves the purpose as well. In this article, we would display minification of output routes of Flask responses using the library - Flask-Minify. Advantages of MinificationWebsites load faster as fewer lines are there to upload and download.Ban
12 min read
Convert CSV to HTML Table using Python Pandas and Flask Framework
In this article, we are going to convert a CSV file into an HTML table using Python Pandas and Flask Framework. Sample CSV file : USERNAME,IDENTIFIER,FIRST_NAME,LAST_NAME booker12,9012,Rachel,Booker grey07,2070,Laura,Grey johnson81,4081,Craig,Johnson jenkins46,9346,Mary,Jenkins smith79,5079,Jamie,SmithStepwise ImplementationCreating Environment Ste
2 min read
How to use Flask-Session in Python Flask ?
Flask Session - Flask-Session is an extension for Flask that supports Server-side Session to your application.The Session is the time between the client logs in to the server and logs out of the server.The data that is required to be saved in the Session is stored in a temporary directory on the server.The data in the Session is stored on the top o
4 min read
How to Integrate Flask-Admin and Flask-Login
In order to merge the admin and login pages, we can utilize a short form or any other login method that only requires the username and password. This is known as integrating the admin page and Flask login since it simply redirects users to the admin page when they log in. Let's is how to implement this in this article. Integrate Flask Admin and Fla
8 min read
Flask URL Helper Function - Flask url_for()
In this article, we are going to learn about the flask url_for() function of the flask URL helper in Python. Flask is a straightforward, speedy, scalable library, used for building, compact web applications. It is a micro framework, that presents developers, useful tools, and, features, for coding REST APIs, and backend data processing, of web apps
11 min read
Web scraping from Wikipedia using Python - A Complete Guide
In this article, you will learn various concepts of web scraping and get comfortable with scraping various types of websites and their data. The goal is to scrape data from the Wikipedia Home page and parse it through various web scraping techniques. You will be getting familiar with various web scraping techniques, python modules for web scraping,
9 min read
Wikipedia Summary Generator using Python Tkinter
Prerequisite: Tkinter Wikipedia Python offers multiple options for developing a GUI (Graphical User Interface). Out of all the GUI methods, Tkinter is the most commonly used method. Python with Tkinter outputs the fastest and easiest way to create GUI applications. Wikipedia is a Python library that makes it easy to access and parse data from "wiki
2 min read
Flask vs Django - Which Framework Should You Choose in 2024
Python isn't just a language; it's a powerhouse of tools that can make a developer's life a whole lot easier. And when it comes to building web applications, Flask and Django are two names that shine brightly. These frameworks are like toolboxes, filled with everything you need to create powerful, elegant web apps without getting bogged down in the
8 min read
Create a Weather app using Flask | Python
Prerequisite : Flask installation Flask is a lightweight framework written in Python. It is lightweight because it does not require particular tools or libraries and allow rapid web development. today we will create a weather app using flask as a web framework. this weather web app will provide current weather updates of cities searched. Basic setu
2 min read
Todo list app using Flask | Python
There are many frameworks that allow building your webpage using Python, like Django, flask, etc. Flask is a web application framework written in Python. Flask is based on WSGI(Web Server Gateway Interface) toolkit and Jinja2 template engine. Its modules and libraries that help the developer to write applications without writing the low-level codes
3 min read
How to Run Python Flask App Online using Ngrok?
Python Flask is a popular web framework for developing web applications, APIs, etc. Running flask apps on the local machine is very simple, but when it comes to sharing the app link to other users, you need to setup the whole app on another laptop. This article provides an interesting way to setup your web app online. Then, you can send the link to
2 min read
Create a Real Time Currency Converter app using Flask | Python
Prerequisite: installation of PythonWhat is Flask in Python ? Flask is a popular and lightweight Python web framework, meaning it is a third-party Python library used for developing web applications. Project Setup : create a new directory and name it 'CURRENCY-CONVERTER'. mkdir CURRENCY-CONVERTER && cd CURRENCY-CONVERTER Inside it create tw
8 min read
How to Build a Web App using Flask and SQLite in Python
Python-based Flask is a microweb framework. Typically, a micro-framework has little to no dependencies on outside frameworks. Despite being a micro framework, practically everything may be developed when and as needed utilizing Python libraries and other dependencies. In this post, we'll develop a Flask application that collects user input in a for
4 min read
Scraping Wikipedia table with Pandas using read_html()
In this article, we will discuss a particular function named read_html() which is used to read HTML tables directly from a webpage into a Pandas DataFrame without knowing how to scrape a website's HTML, this tool can be useful for swiftly combining tables from numerous websites. However, the data must have to be cleaned further, So let's see how we
3 min read
Fetching text from Wikipedia's Infobox in Python
An infobox is a template used to collect and present a subset of information about its subject. It can be described as a structured document containing a set of attribute-value pairs, and in Wikipedia, it represents a summary of information about the subject of an article.So a Wikipedia infobox is a fixed-format table usually added to the top right
3 min read
How to Extract Wikipedia Data in Python?
In this article we will learn how to extract Wikipedia Data Using Python, Here we use two methods for extracting Data. Method 1: Using Wikipedia module In this method, we will use the Wikipedia Module for Extracting Data. Wikipedia is a multilingual online encyclopedia created and maintained as an open collaboration project by a community of volunt
5 min read
Wikipedia module in Python
The Internet is the single largest source of information, and therefore it is important to know how to fetch data from various sources. And with Wikipedia being one of the largest and most popular sources for information on the Internet. Wikipedia is a multilingual online encyclopedia created and maintained as an open collaboration project by a com
3 min read
Build a Text Translator Web App using Flask and Azure Cognitive Services
We're going to create a website that will translate text into multiple languages using Artificial Intelligence(AI). We'll use Flask framework for the Front end and Azure Cognitive Services(collection of AI services) for the Back end. To get started writing our Flask application with Python, we need to set up our development environment, which will
7 min read
Making a Flask app using a PostgreSQL database
The Postgres database can be accessed via one of two methods in Python. Installing PgAdmin4 is the first step because it offers a user interface for interacting with databases and another for using the psycopg2 connector. In this post, we'll concentrate on a different approach that lets us alter the Postgres database: using the psycopg2 connector.
4 min read
Placement Prediction App using Flask
Machine learning is a widely employed method for making predictions. Numerous algorithms are accessible in different libraries for predictive tasks. In this article, we'll construct a placement prediction model using Random Forest Classifier with historical data and later we will store that model to .pkl file to integrate it with our Flask app usin
9 min read
Joke App using Bottle Framework - Python
There are many frameworks in python which allows you to create webpage like bottle, flask, django. In this article you will learn how to create simple app bottle.Bottle is a fast, simple and lightweight WSGI micro web-framework for Python. It is distributed as a single file module and has no dependencies other than the Python Standard Library. Inst
2 min read
Deploy Python Flask App on Heroku
Flask is a web application framework written in Python. Flask is based on the Werkzeug WSGI toolkit and Jinja2 template engine. Both are Pocco projects. This article revolves around how to deploy a flask app on Heroku. To demonstrate this, we are first going to create a sample application for a better understanding of the process. Prerequisites Pyt
2 min read
Live Search Using Flask And jQuery
In this article, we will do a live search in Flask using Jquery. Live search means that whenever a user type any letter in the input box then all the words containing that letter will be shown. Installation This module does not come in-built with Python. To install it type the below command in the terminal. pip install flask After installing the fl
2 min read
Create a Counter App Using React, Tailwind and Django Framework
This article will guide you in creating a Counter using React and Tailwind with the Django Framework. We’ll explore the integration of Django, React, and Tailwind, and go through the step-by-step process of implementing the Counter in Python using the Django Framework. What is Counter App?The Counter app is a straightforward tool designed for easy
6 min read
How to Build a Simple Android App with Flask Backend?
Flask is an API of Python that allows us to build up web applications. It was developed by Armin Ronacher. Flask’s framework is more explicit than Django’s framework and is also easier to learn because it has less base code to implement a simple web-Application. A Web-Application Framework or Web Framework is the collection of modules and libraries
8 min read
Dockerize your Flask App
Python provides many ways to distribute your python projects. One such way is by using an important technology called Docker. Docker is an open-source application that allows administrators to create, manage, deploy, and replicate applications using containers. It is basically a platform that enables developers to make their applications portable b
4 min read
Flask project - Create a Joke App with PyJokes
Flask is a micro web framework written in Python. It is classified as a micro-framework because it does not require particular tools or libraries. Flask is a lightweight WSGI web application framework. It is designed to make getting started quick and easy, with the ability to scale up to complex applications. For creating joke app we need two libra
2 min read
Practice Tags :