As long as the code is running inside an iframe it won’t work. But that is not how you would normally run it.
You can see it working if you use the Debug View. Click the View button to the right of the Settings button and click the Debug mode menu item. The page will open in a new tab without the iframe and the tweet button will/should work as expected.
As said, the normal views in Codepen are running inside an iframe.
If you mean a GitHub page that would be fine. But if you try to submit a repo you will get the message “Remember to submit the Live App URL.”. So it has to be to a live working site.