Skip to content
Related Articles

Related Articles

Joke App using Bottle Framework – Python
  • Last Updated : 16 Feb, 2021
GeeksforGeeks - Summer Carnival Banner

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.


First we have to install the necessary modules

pip install bottle
pip install pyjokes

You  get funny one-liner, mostly related to programming by using just importing a library known as pyjokes.

Some Methods Of pyjokes Library

There are two methods in pyjokes- get_joke() and get_jokes().  

get_joke()– It only returns one joke. We get random joke each time.

Parameters – There are two parameters- language and category. You can choose from the language and category above.

Return Type – It return string type (str).

get_jokes() – Here, we get a list of jokes.  

Parameter– The parameters are same as above- language and category.

Return type– list.

Languages Supported By pyjokes:

  • English – ‘en’
  • German – ‘de’
  • Spanish – ‘es’
  • Galician – ‘gl’
  • Basque – ‘eu’
  • Italian – ‘it’

Categories Included In pyjokes:

  • For geeky jokes -’neutral’ (It is chosen by default)
  • For Chris Norris Jokes – ‘chuck’.
  • If you want all type of jokes – ‘all’
  • There is one more category known as ‘twister’ which only works for the German Language (‘de’). This mostly includes tongue twister.

Create new directory for project Joke_app

Inside that create a file


from bottle import route, run, template
import pyjokes
def index():
    return template('index.tpl',{'joke':joke})
run(host='localhost', port=8080,debug=True)

Then create new directory and name it as views

Inside that create new file indes.tpl



To run the app open terminal or cmd


Output :-

Attention geek! Strengthen your foundations with the Python Programming Foundation Course and learn the basics.

To begin with, your interview preparations Enhance your Data Structures concepts with the Python DS Course.

My Personal Notes arrow_drop_up
Recommended Articles
Page :