Skip to main content
  1. My Blog Posts and Stories/

Making a repo of Jokes

··248 words·2 mins

Le Me was bored again…. #

After all the deliberating on what I am supposed to do for the website, I decided to make a database of jokes in order to spread joy and laughter to others. While I’m at it, why not make some lame jokes :D.

Database boi #

As I am still a database SCRUB, I decided to use one-liner jokes in a text file and parse it based on that. I copy and pasted some jokes from an API (Can’t remember what it is but if you know who it is please let me know) and stored them into a text file. Oh boy, time for my good old friend python

# Read the code
with open('jokes.txt') as file:
    data = tuple(map(lambda x: x.strip(), file.readlines()))

# Load the route to the page
@app.route('/jokes', methods = ['POST', 'GET'])
def jokes_page():
    # Search algorithm here
    # Random joke will be picked when u access the page at the start
    return render_template('jokes.html', jokes = jokes_list)

Hopefully, after I learn more about databases this semester, I will be able to put all this stuff into a database and load it from there.

On a side note…. #

Meanwhile, if you guys have any recommendations for one-liner jokes to be added to the database, please do let me know. If I find them funny, I will add your name to the credits of the jokes. (Hopefully my jokes are funny enuf)

You can see the jokes here (Page does not exists anymore)