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 app.py
Then create new directory and name it as views
Inside that create new file indes.tpl
To run the app open terminal or cmd
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.