It’s for my Python Course. It provides only very basic HTTP, but yet can be used for simple WWW hosting. Source.
Features:
- GET and POST methods
- New thread for new connection
- Directory listing
- Error pages
- Document index
- Deafult type and charset
- Python scripts ;)
- Configuration file
- … and my own modules to handle these
TODOs:
- Logging
- Much more stability (exceptions handling, etc.)
- Sending gzipped or chunked data (if accepted)
- Range headers
- … and many, many other
To run just edit pyhttpd.conf and change Port and Document root. Then type “python pyhttpd.py” and it should be now listening for connections.
How to run a python script and its output send to client? Pyhttpd checks if the requesting file is a python one. If so then it opens a python interpreter by a pipe, sends _GET and _POST dictionaries and file contents. And finally, sends interpreter outputs to client.
_GET and_POST are just dictionaries with variable names as keys. So if there is a foobar.py?i=500 request then _GET will be { ‘i’ : ’500′ } (note that this is always a string value).
It’s GPL if someone asked.
Some of you may have my email address or JabberID. Here are my three official mails/JIDs:
- ponton616 at gmail com
- ponton at jabster pl (I created this cause I don’t like my gmail login ;))
- tomasz.maciejewski at jabster pl (I wish it to be alias, but it’s impossible)
I check other accounts, but I don’t promise I won’t remove them.
All right. I said I’ll show my jzwi source and here it is: http://www.srednikpe.org/src/jzwi/
It is almost ended. It doesn’t only check local variable if they have unique names. I’m too lazy to do that. But after all it works fine and quite fast (compared to other interpreters written by my colleagues).
To run jzwi program just run “jzwi program.jzw argument1 argument2 …”.
It’s all licensed on GPL (any version). There is no guarantee that it’ll work. ;)
Uff… I have nearly finished my jzwi interpreter, just few minor fixes I will make in a week…
JZWI means “Język z wykładu improved” (“Language from lecture improved”). On our programming language theory subject we defined syntax using BNF notation and then we define formal semantic of this language (which is quite simmilar to Pascal/ALGOL).
It was our lab project to write a parser, converter to xHTML/LaTeX, an interpreter or full compiler in Haskell. It wasn’t as difficult as I thought, but I had to rewrite many parts of the code, ’cause firstly I wrote only simply parser, then simply converter and then I decided to try interpreter.
It costed me few nights and days, but I am very happy, when I see how beautifully it runs insertion sort. ;) Full source will be uploaded within few days. I have to lay off from vim and ghc. ;)
Uff… maybe I’ll check insertion sort once more. :>
Recent Comments