Wednesday 16 March 2016

MacBook as a server

Wow! I just discovered that my MacBook works just like the Raspberry Pi and can run a Python-based web server. Of course I should have realised that as OSX is based on Unix and very like Linux.

1. Create a valid file "index.html" in a suitable folder(directory), for example using TextEdit, on the "Desktop".

2. Open the Terminal app, at the "$" prompt enter

  $ cd Desktop
  $ ls
   index.html
3. Run the command to start the server
  $ python -m SimpleHTTPServer 8000
    Serving HTTP on 0.0.0.0 port 8000 ...
4. Open a browser on the MacBook or any other computer on your local network and go to the following URL (of course substitute your Mac's name in place of "ganymedebook"...)
  ganymedebook.local:8000

Note: My MacBook is named "GanymedeBook". Look in the Apple Menu > System Preferences > Sharing panel" where you can edit your computer name.

Your browser will display the "index.html" file you created. In my case it was the HTML part of the LIGHT CONTROL page I described earlier for Home Automation:

Screen Shot 2016 03 22 at 11 37 41

A LOT to learn!!!

I have learned a lot: "C" programming (for my Arduino stuff), "Python", "CGI", "UNIX & Shell", "Java", "Javascript", "HTML" and "CSS" - 9 languages for all this computer stuff I have been doing... that's a lot to remember, and I often get confused with the syntax of one with another. Oh for one language, but I guess that won't happen. And now the BBC is going to confuse our kids even more with a couple of Microsoft inventions for its micro:bit board...

No comments: