Update server.py

Add shebang, add encoding, add license, rename and refactor a bit.