I’m having a issue on graded lab for Module 3 (World Tour & Flight Finder)
I successfully passed on the graded lab, but couldn’t execute exercise 3. The restart_widget() function from the last code cell does not finish executing.
Can anyone help me with this?
This is normal and expected behavior.
The restart_widget() function starts a Flask web server to run the interactive widget. Because the server runs in the foreground, the cell stays in the executing state ([*]) to keep the web server alive. If the cell finished executing, the server would stop, and the widget would not load.
You can keep interacting with the widget in your browser while the cell is running. When you want to stop the server to rerun it with changes or run other cells, click the Stop (■) button in the Jupyter toolbar to interrupt the kernel.
It worked! Thank you very much!
There are 2 more things I want to point.
The first one is that the original code for the restart_widget funcion returned a error. I passed the code to the GPT environment and it fixed the code for me.
The second one is that, even though I enabled the following features (set to True) in the widget_config.js file but couldn’t see any of them in the output platform:
- darkMode
- enableDarkModeToggle
- enableExportButton
- enableShareButton
- enablePrintButton
Other changes like alternativeRoutes worked.
Do you know where these features appear in the platform?
1. The restart_widget Error
Glad you got it working. If you still have the fix GPT gave you, feel free to share what the original error was. Helps us track if it’s a platform-specific issue worth flagging to the course team.
2. Missing Features (Dark Mode Toggle, Export, Share, Print)
Those config flags exist in widget_config.js but the HTML template (templates/tour_widget.htm) doesn’t have the UI or logic to support them. The template only reads a few config properties:
- Theme colors (primaryColor, backgroundColor, etc.)
- Text labels (pageTitle, button text)
alternativeRoutes (the only features.* property actually wired up)
debugMode
For darkMode.enabled, the JS adds a CSS class dark-mode to the body, but there are no corresponding CSS rules in the template, so nothing visually changes.
The toggle, export, share, and print buttons simply don’t exist in the HTML. To make them work, give your LLM both static/widget_config.js and templates/tour_widget.htm and ask it to add the actual HTML elements and JS logic for those features.
That’s the error i’m getting with the original code:
About the other functions, thank you for the explanation. I’m gonna give it a try with the LLM!
Thanks for sharing the traceback.
The bug is on this line in restart_widget():
for proc in psutil.process_iter(['pid', 'name', 'connections']):
'connections' is not a valid attribute name for process_iter’s attrs parameter. In newer versions of psutil, the valid attr name is 'net_connections', not 'connections'. The fix is to just remove it from the list:
for proc in psutil.process_iter(['pid', 'name']):
The code already calls proc.connections() directly inside the loop, so prefetching wasn’t needed in the first place.
Good luck with the LLM customization!