1. If you want your computer to act as a server, you need to disable sleep completely.
You can keep "Spin down disk" enabled, as it will automatically spin up again when needed. The main effect of disk spindown is that the first client request after spindown that needs the disk will take several seconds. Subsequent client requests within the spindown window will be fast. This only applies to a spinning disk, not an SSD.
I run a Mac mini as a server like this: sleep disabled, spindown at 10 mins.
2. If you only run your Python script sometimes, and don't want to disable sleep completely, then use the 'caffeinate' cmd when you run your script.
https://developer.apple.com/legacy/...win/Reference/ManPages/man8/caffeinate.8.html
If you then terminate your script, the sleep-disabling assertion will disappear, and the machine will sleep again using whatever timeouts are in force.
3. Personally, I might not rule out a Pi. Pi Zero, $5:
https://www.adafruit.com/product/2885
It depends on a number of factors, mostly involving power supply, connectors, and what I wanted the server to do overall, but $5 is pretty cost-effective.