I would like to program a computer game which should be played by several participants. And I need to do it in two different ways. The first way is to program a web site where people can login and play. The second way is to have programs running locally and exchanging data with each other using P2P approach.
I know how to program both ways. In the first case I can use PHP. In the second way I use Python or Java. But in this case I need to do the same work twice (using different languages). And I want to avoid that (so, my question is how can I do it).
I almost solved my problem but in the end I have realized that it will not work this way. I wanted to use JavaScripts. I thought that with the JavaScript I can program an interface for the game which reads from and writes to a local file. And then, in the case of the web server I upload and download the local file to the server. And in the case of P2P approach I use Java or Python networking tools to exchange the local files between the user's computers.
But then I found out that JavaScript cannot read data from a web server. So, my idea failed. Does anybody have better ideas?