The App of Drag: Natural Language Processing, Python and Drag Race (Part 1)

Skull and Zen™️
Plain Simple Software
3 min readOct 25, 2022

To say I am a fan of RuPaul’s Drag Race is a total understatement. That show is literally a part of my mental health package. It brings so much joy to so many fans and it’s a staple in the community. To blend my love of the show and my love for programming and NLP, I created an app to perform various Natural Language Processing tasks on different tweets and subreddits from the web. My app connects to an amazing new API called The Text API. This web NLP API offers a variety of functions to allow easy development utilizing text analytics and Natural Language Processing. My application is still a work in progress but it is my living love letter to the show. Let’s dive into some code and break down the steps I took to create the App of Drag.

Photo from RuPaul’s Drag Race — Wikipedia

Flask Frameworks and Python

The Flask framework was my first hurdle to jump. It lays the foundation for the app and building this first will allow me to fill in the juicy details in an organized way. I’m all about that life so that’s where I started. It’s good practice to create a virtual environment when coding in Python. That’s always the first step I take. Once I created mine, I could continue with the tasks. To create a Flask application, you must first install Flask.

pip install flask

Once installed, I can continue on with the code. I import the object of a Flask class as my WSGI app. WSGI stands for Web Server Gateway Interface. It is a specific type of interface that describes the communication between web servers and Python web frameworks. Next the Flask constructor, which is used for instantiating objects, will take the name of the current module as an argument. The Flask class has a decorator function called the route() function. This gives the app the path of the URL for the associated function code. The main driver will then execute to run the application on my local development server. The following code is a generalized starting point that illustrates these steps.

from flask import Flaskapp = Flask(__name__)@app.route(‘/’)
def superFan():
return ‘I am a Drag Race Super Fan!’
if __name__ == ‘__main__’:
app.run()

In the command line, I then type “flask run” and I should see the following returned.

I go to the URL displayed here and the first page of the application is shown.

Yaaaaaasssss, Hunty! We have the beginnings of our beloved application. In Part 2 of this series, I’ll upgrade the app to include HTTP requests and more. Stay Tuned!

If you enjoyed this brief tutorial, please follow me, Z. Myricks, for more guides in all things Python and Natural Language Processing. Make sure to follow Plain Simple Software for more software articles!

--

--

Skull and Zen™️
Plain Simple Software

A space to ground, for spiritual self-care, and to cultivate mindfulness.