CLOSE ✕
Get in Touch
Thank you for your interest! Please fill out the form below if you would like to work together.

Thank you! Your submission has been received!

Oops! Something went wrong while submitting the form

WordCloud Generator using Python and Flask

The moment you start learning something new about coding or new techniques to build new systems, it urges you to build a project out of it, out of everything that you have learned.

Recently, engaging myself in training about data science and data visualization, I came across a python library called wordcloud. It is a Data visualization method to represent data into a form of wordcloud. Focusing on this idea, I built a local web app for creating wordclouds. Even the most unfamiliar person could generate wordclouds using this web app.

Step 1: Building the front end

Homepage

The frontend uses HTML5 and Bootstrap for easy to understand user interface. Integrating multiple web pages for blog, contact and most importantly, the wordcloud generator. This is how the form looks.

wc-generator

This form is for users entering their desired wordcloud string with other parameters as well. It is flexible enough as the user can enter values depending on the minimum and maximum values mentioned in the textbox. It also mentions the default(suggested) value for every input term.

Step 2: Developing app.py

app.py is the main application file used to run the python code with the web application.

All the parameters and input values from the form are accepted using the POST method and stored into variables after typecasting. The same variables are passed as parameters to the wordcloud generator method of the wordcloud library. The app.py file not only links the form code but also the rest of the webpages that are referenced through every button or link.

Step 3: Integrating all the files with proper reference

App.py is not the only file with code. HTML web pages are to be linked in the route method of the app.py file

As shown in the above code, route method references to the contact.html page once it is clicked in the web app or the path is mentioned in the URL. Once all the files are linked with the app.py file, your web application is ready to run.

Running your web application:

  1. Open your command prompt
  2. Navigate to the directory where all the files are stored
  3. Type: python app.py
  4. Open browser and type: localhost:5000
  5. Your web application is ready to use

Step 4: Generating wordcloud

You are ready to click the generate wordcloud button, that is the last step of all these.

Enter string: steve jobs

And using all the default parameters, the output is

Steve Jobs wordcloud

That is all!

Future Work:

It is always recommended to be updated with whatever you have learned. This web application is to be deployed using the Heroku app so that it could be used globally. Heroku app is a cloud service provider used to deploy projects so that it could be used globally. This enables multiple users to use the deployed project and no need to clone the build from GitHub.

Anyway, you can view the entire code here.

Any recommendations are welcomed! Thank you!

Shivang Raikar
3 min read
@Medium

Recent Blog Posts

Let's connect.
Contact Me