How to Create Web Apps with Python, HTML and Thonny

Create Web Apps with Python, HTML and Thonny
(Image credit: Tom's Hardware)

Python is a glue. We can use it to join different elements of code together. As a language, Python is easy to learn, and human readable which makes it one of the most effective languages for learning and general purpose programming. Part of Python’s charm are the many modules of code which can be easily inserted into a project. 

Thonny is a powerful yet simple editor for Python and, with the release of version 4, we wanted to use it to create a project. In this how to we shall use the latest version of Thonny to create a web application that will pull Raspberry Pi stock data from rpilocator.com and use it to populate a table in our app.

Latest Videos FromTom's Hardware
TOPICS
Les Pounder
Associate Editor

Les Pounder is an associate editor at Tom's Hardware. He is a creative technologist and for seven years has created projects to educate and inspire minds both young and old. He has worked with the Raspberry Pi Foundation to write and deliver their teacher training program "Picademy".

  • Christopher_115
    "5. Click on “Run anyway” to continue. "

    That's a negative, Ghostrider.
    Reply
  • brandonjclark
    "Part of Python’s charm "

    PyCharm: the Python IDE for Professional Developers by JetBrains

    I see what you did there... ;)
    Reply
  • brandonjclark said:
    "Part of Python’s charm "

    PyCharm: the Python IDE for Professional Developers by JetBrains
    I see what you did there... ;)
    Just use Microsoft code with the appropriate plug-ins. No need for that IDE at all especially if it’s not free. I use sublime text anyway for all my development purposes I don’t need any extra garbage

    Nobody needs a fancy IDE for python LOL

    There editor looks just like Microsoft code which is based on Atom
    Reply
  • Bo-W4GHV
    Looked interesting, but way over my head, I gave it a try. I got the following errors and don't have a clue. I sent them to the feedparser author of possible help.
    I'm still at the beginner level trying to get cute graphics and menus on the screen with TKinter. :)

    Traceback (most recent call last):
    File "C:\Users\Bo\Downloads\Adafruit_CircuitPython_MatrixKeypad-main\examples\RSS-Feed-Reader.py", line 3, in <module>
    import feedparser
    File "C:\Users\Bo\AppData\Roaming\Python\Python310\site-packages\feedparser\init.py", line 39, in <module>
    from . import api
    File "C:\Users\Bo\AppData\Roaming\Python\Python310\site-packages\feedparser\api.py", line 54, in <module>
    from . import http
    File "C:\Users\Bo\AppData\Roaming\Python\Python310\site-packages\feedparser\http.py", line 44, in <module>
    _base64decode = getattr(base64, 'decodebytes', base64.decodestring)
    AttributeError: module 'base64' has no attribute 'decodestring'

    73, Bo W4GHV since '54
    Reply
  • MisterWho
    decodestring() does no longer exists from v3.9. Checkout this docs, use base64.decodebytes() instead.
    Reply
  • Bo-W4GHV
    Thanks! Strangely the program had a comment to that change but failed to fix it!🤔
    Fixing it in 2 files fixed it and it 'ran'
    However the web page results has a list of new errors!
    I'll list them but don't worry/bother if fixing it is a mess.
    Again over my head but looked like one I could get going. 73. Bo

    Traceback (most recent call last):
    File "C:\Users\Bo\AppData\Roaming\Python\Python310\site-packages\pywebio\session\threadbased.py", line 86, in main_task
    target()
    File "C:\Users\Bo\Downloads\Adafruit_CircuitPython_MatrixKeypad-main\examples\RSS-Feed-Reader.py", line 5, in main
    stock = feedparser.parse('https://rpilocator.com/feed/')
    File "C:\Users\Bo\AppData\Roaming\Python\Python310\site-packages\feedparser\api.py", line 238, in parse
    data = convert_to_utf8(result, data, result)
    File "C:\Users\Bo\AppData\Roaming\Python\Python310\site-packages\feedparser\encodings.py", line 244, in convert_to_utf8
    if isinstance(proposed_encoding, collections.Callable):
    AttributeError: module 'collections' has no attribute 'Callable'
    Reply
  • Bo-W4GHV
    Bo-W4GHV said:
    Thanks! Strangely the program had a comment to that change but failed to fix it!🤔
    Fixing it in 2 files fixed it and it 'ran'
    However the web page results has a list of new errors!
    I'll list them but don't worry/bother if fixing it is a mess.
    Again over my head but looked like one I could get going. 73. Bo

    Traceback (most recent call last):
    File "C:\Users\Bo\AppData\Roaming\Python\Python310\site-packages\pywebio\session\threadbased.py", line 86, in main_task
    target()
    File "C:\Users\Bo\Downloads\Adafruit_CircuitPython_MatrixKeypad-main\examples\RSS-Feed-Reader.py", line 5, in main
    stock = feedparser.parse('https://rpilocator.com/feed/')
    File "C:\Users\Bo\AppData\Roaming\Python\Python310\site-packages\feedparser\api.py", line 238, in parse
    data = convert_to_utf8(result, data, result)
    File "C:\Users\Bo\AppData\Roaming\Python\Python310\site-packages\feedparser\encodings.py", line 244, in convert_to_utf8
    if isinstance(proposed_encoding, collections.Callable):
    AttributeError: module 'collections' has no attribute 'Callable'
    I traced down all the comments and it looks like the problem is with the https://rpilocator.com/feed error listed.
    Headed there now. A 'RPI locator' will find about 6 of them here.😂
    Reply
  • Bo-W4GHV
    Bo-W4GHV said:
    I traced down all the comments and it looks like the problem is with the https://rpilocator.com/feed error listed.
    Headed there now. A 'RPI locator' will find about 6 of them here.😂
    WAIT! How dumb I am. I actually have closer to 10 Pi's and need NO more.
    I was thinking it could be easily modified to do for 'fun' /educational things.
    I probably should quit this one.

    Earlier I struck out just trying to scrape the solar data from https://www.hamqsl.com for a cute display.

    I am succeeding in getting a Pi, tkinter,Python, arduino, stepper motor controlling a mag loop antenna.
    Reply
  • MisterWho
    Bo-W4GHV said:
    Thanks! Strangely the program had a comment to that change but failed to fix it!🤔
    Fixing it in 2 files fixed it and it 'ran'
    However the web page results has a list of new errors!
    I'll list them but don't worry/bother if fixing it is a mess.
    Again over my head but looked like one I could get going. 73. Bo

    Traceback (most recent call last):
    File "C:\Users\Bo\AppData\Roaming\Python\Python310\site-packages\pywebio\session\threadbased.py", line 86, in main_task
    target()
    File "C:\Users\Bo\Downloads\Adafruit_CircuitPython_MatrixKeypad-main\examples\RSS-Feed-Reader.py", line 5, in main
    stock = feedparser.parse('https://rpilocator.com/feed/')
    File "C:\Users\Bo\AppData\Roaming\Python\Python310\site-packages\feedparser\api.py", line 238, in parse
    data = convert_to_utf8(result, data, result)
    File "C:\Users\Bo\AppData\Roaming\Python\Python310\site-packages\feedparser\encodings.py", line 244, in convert_to_utf8
    if isinstance(proposed_encoding, collections.Callable):
    AttributeError: module 'collections' has no attribute 'Callable'


    AttributeError: module 'collections' has no attribute 'Callable'

    Removed from v3.10


    In the article the author uses Thonny 4.0.0.

    Thonny 4.0.0 comes with Python 3.10.6 - this script would've NEVER worked without any error! O.o
    Reply