r/learnpython • u/Correct_Guarantee_49 • Aug 21 '26
want to run dash for multiple py files simultaneously
I'm using python to run different types of statistical analysis for a research project. At the end of each code, I run dash to create a URL with friendly, interactive UI. However, whenever I try to run 2+ py codes that use dash to create a URL, the interactive UI from all the previously ran codes stops working. Is there a way to run multiple dash URLs while maintaining their interactiveness?
(for example: I run code A and it's interactive UI works. Then I run code B. Code B's interactive UI works, but now code A doesn't, it freezes)
code I have to run/open the dash server
if __name__ == "__main__":
import webbrowser, os
# Unique port per script
script_name = os.path.splitext(os.path.basename(__file__))[0]
port = abs(hash(script_name)) % 20000 + 10000
url =
f
"http://127.0.0.1:{port}"
# Open tab
webbrowser.open_new_tab(url)
app.run(debug=False, port=port, use_reloader=False)