Real Dictionary application using Python/Flask

In this article, we going to build the Dictionary using which we can get the meaning of the given word.


  • Python environment

Let's build the application!

  • Create the virtual environment in python and install the following packages
pip3 install flask
pip3 install PyDictionary

1. Create the file called and use the below code:

from flask import request, redirect, Flask, render_template
from PyDictionary import PyDictionary

app = Flask(__name__)

@app.route('/', methods=['GET', 'POST'])
def search():
    if request.args.get('keyword'):
        str_to_search = request.args.get('keyword')
        dictionary = PyDictionary()
        result = dictionary.meaning(str_to_search)
        except Exception as e:
            result = "Unable to find your search"
        return render_template("index.html", meaning = result,str_to_search=str_to_search)
        return render_template("index.html")

if __name__=='__main__':

2. let's create the template file index.html under the folder "templates" and use the below code:

<!DOCTYPE html>
<html lang="en">
    <style type="text/css">
    margin: 15px auto;
    padding: 30px;
    background: #e8dde2;
    width: 900px;
    border-radius: 8px;
    box-shadow: 4px 6px 10px #999;
    <meta charset="UTF-8">
    <link rel="stylesheet" href="">
  <script src=""></script>
  <script src=""></script>
<section class="section-class">
    <div class="">
    <form action="/" method="get">
        <div class="form-group">
            <input type="text" name="keyword" placeholder="Text to Search" class="form-control"></input>
        <div class="form-group">
            <input type="submit" value="Search" class="btn btn-primary"></input>
    <div class="" style="font-size: 15px;font-style: italic;"><strong><span style="font-size: 13px; fon-size: normal">{{str_to_search}}</span></strong> : {{meaning}}</div>

3. when we run the below command in the terminal/command prompt you'll get the URL


4. copy and paste the returned URL in browser, Booom!!! there you go!!! like below Happy Searching :)

Screenshot 2022-10-13 at 11.45.43 AM.png