Restructured server.R.
Made demo.py more generic