Before jumping to embrace a framework, consider switching from an editor to an IDE. VSCode, Cursor or PyCharm come to mind (the vi vs Emacs debate is just hilarious).
Poke around with AI like GitHub Copilot or Cursor to gain insight into improvement suggestions. Embrace version control (git) and automated deployment (e.g. GitHub Actions) I found CodeRabbitâs code reviews super helpful.
Once you are there, take a hard look at your code. Since client side code is JavaScript, you could consider a JS framework like Vue - removes one language. Have a look and pick what works for you