Apr 20, 2012

Simple web server

Ever find you need to implement a web server or provide some web pages on a local network? Maybe you don't have an Apache server up and running or don't want to go to the trouble of configuring it. I've found this with Natural Docs documentation, where the tools will generate a bunch of .html files that you can read locally if you are on the machine where they are generated. Pygments also will generate html formatted files that you might want to serve. However, you might want to make them accessible to a small team. Here is a quick trick that can make this task very simple. Python ships with a basic HTTP server module. You can get it up and running, serving files from a given directory down with the following command:

python -m SimpleHTTPServer

and that's all there is to it! The default port will be 8000, but you can provide a different port on the command line (just add the port number after the SimpleHTTPServer - any number above reserved range of 0-1024 will work. The server will be accessible to any machines that can see that port on the machine it is running on. The server won't handle a high load and isn't particular secure, so I wouldn't make it available to the general public. But if you need to serve some pages quickly and simply, to a small number of users within a private network, this can be a really fast way to get to that point. If and when the load becomes an issue, or security concerns are important, then a heavyweight server like Apache is a much better choice.

Once the server is up and running you access it via a web browser at http://machine_name:8000 File paths are all relative to the directory the server is running in. If there is an index.html in that directory, it will be loaded by default when you access the server at that URL.

There are comments.

Apr 26, 2009

dd-wrt

dd-wrt

Just installed dd-wrt on my Linksys wrt54g wireless router. I'd been meaning to do this for a while - as an easy way to get a much more functional router than the default firmware shipped by Linksys. What finally motivated me to do it was the recent storm about Time Warner Cable introducing bandwidth caps in Austin. Although TWC seem to have backed down for the moment, they have also recently started disconnecting customers for 'using too much bandwidth' on their infinite bandwidth contracts. The DD-WRT firmware gives me an independent way to monitor my usage and get an idea of how much I typically transmit & receive.  

The DD-WRT firmware install wasn't quite as smooth as the documentation might make you believe. The first time I installed and then tried to update the firmware, I got a fairly unhelpful 'Error 2: Access violation' error from the tftp prompt and not much else. I went back through the management mode initial vxkiller upload and things seemed to work better the second time around. For a while I was worried that I had a brick of router.

Once back up and running, the settings were very similar to the previous Linksys options, so it was quite quick to get the wireless settings and port forwarding, DMZ etc that I was using previously reconfigured. Now I have historical and realtime graphs of bandwidth usage available. Should be interesting to be able to monitor what's going on. If they are cutting people off for using 44GB per week and saying that is “that is more than most people use in a year” I am a little concerned at my 7.2GB in one day. That was a few iPhone development videos from Stanford and then we watched Quantum of Solace last night on the Xbox. Seems like Time Warner consider that aberrant behaviour.

There are comments.

Feb 16, 2009

stop & search

a cold day in London

One of the least enjoyable experiences on a recent trip to London, last week, happened while I was taking pictures of the London eye. I was standing a few hundred meters away, shooting with a normal point and shoot camera, just like all the people around me, when a couple of police officers approached me. I'd heard about photographers being hassled in London but was surprised this managed to happen to me within 48 hours of arriving in the city. They started out by saying that 'they didn't really believe I was a terrorist, but were stopping photographers to make people aware that they were watching what was going on'. From there, they handed me a form that listed my rights under section s44 of the anti-terrorism law then proceeded to question me about what I was doing, where I was from, why I was taking pictures.

As far as I can tell, even though they themselves said they have no reasonable clause, the Terrorism act says that's fine. We spent about 5 minutes going through where I've lived and having me justify why I take pictures. Then they wanted to see all the pictures I'd been taking (again, as far as I can tell, in contradiction of their own guidelines on collection of evidence). On looking through the images, one of the officers stated that 'those look just like the sorts of pictures a terrorist would take' and then told me to move on. The picture above is what I was taking, when the stopped me. I got a 'stop and search' form listing that the stop was authorised under the anti-terrorism laws and that was part of a 'pre-planned op'. I can only assume from that they the London police have decided to institutionalise harassing photographers for the sake of   security theatre. Particularly, if when they find images that they think would be typical terrorist images, they wave the photographer on.

This is all in a city that seems to have more CCTV cameras everywhere than there are people. I'm not quite sure who if anyone is actually watching these camera feeds. The whole thing is quite worrying, for someone who has been out of the UK for a few years. We used to make jokes about books like 1984 or movies like V for Vendetta but it seems that piece by piece typical rights to privacy are being whittled away by a government that is using good intentions to grab as much additional powers as possible. Sure, it is just hassling a photographer in the street, taking pictures of a tourist attraction for no reason, but each time has an increasing chilling effect on what people feel they can do and what government authorities can get away with doing. I didn't argue with the particular officers, mainly as I didn't want to spend half my day discussing it in a police station on my holiday. Maybe that's part of the problem too.

'There's an implicit admission that Section 44 stops and searches do not detect terrorists. This is borne out by the available data. In the financial years 2003/4 to 2006/7, the Met stopped and searched 31,797 pedestrians using the powers of Section 44(2); of these only 79 were arrested in connection with terrorism - less than a quarter of a percent - and even fewer will be convicted. The purpose of deterring is feeble considering the extent to which the Home Office is ready to go to avoid revealing when and where the exceptional powers for Section 44 apply.'

At the end of this five minute waste of time, they started asking me about the number of megapixels my camera had, commented on how impressed they were by the quality of the pictures on the screen and asked where they could buy one and if I'd recommend it.

There are comments.

Jul 14, 2008

unthinkable futures from the past

I found this list from 1993, where Brian Eno and Kevin Kelly throw out wild and wacky things that might happen. Some of them seem a whole lot more likely from 15 years in the future. To me the ideas on the appeal of US citizenship seems to already be starting to happen, with an economy where multiple citizenship and an ability to easily move and work is a competitive advantage. The US tax laws in particular don't endear me to becoming a US or dual citizen.

The idea of squatter's suburbs, where the more affluent return in droves to city centers, driven in part by rising gas prices, and displace the poor appears to be a quite likely outcome now. Probably not such a trend a decade and a half ago.

There are comments.

Jul 11, 2008

viigo

I've had a Blackberry Curve for a while. Really like having a real keyboard and the screen is big enough to actually browse web pages on and read quite a bit of text. However, the built-in web browser is about the worst I've ever used. Slow, clunky, painful. I have been using Google Reader's mobile view to catch up on RSS feeds and blogs while out and about. A few days ago I downloaded the free Viigo feed reader. A huge improvement! Heartily recommend it.

The setup was a painful, as their web site wasn't particularly fast or flexible to edit feeds. Once I realised you could download an OMPL format list from Google reader and upload it to Viigo things went much more smoothly. You can also link it directly to an aggregator feed, such as Google reader. This then keeps track of feeds that you add or remove from the other viewer, but it doesn't sync up what was read between each view, which would be a really nice feature.

Other than the setup issues, I've found it great to use. Clean interface, fast and without the pain of being in the browser environment. The price is good too!


There are comments.