views:

255

answers:

4

Goal: simple browser app, for navigating files on a web server, in a tree view.

Background: Building a web site as a learning experience, w/ Apache, mod_python, Python code. (No mod_wsgi yet.)

What tools should I learn to write the browser tree? I see JavaScript, Ajax, neither of which I know. Learn them? Grab a JS example from the web and rework? Can such a thing be built in raw HTML? Python I'm advanced beginner but I realize that's server side.

If you were going to build such a toy from scratch, what would you use? What would be the totally easy, cheesy way, the intermediate way, the fully professional way?

No Django yet please -- This is an exercise in learning web programming nuts and bolts.

+10  A: 

First, switch to mod_wsgi.

Second, write a hello world in Python using mod_wsgi.

Third, change your hello world to show the results of os.listdir().

I think you're approximately done.

As you mess with this, you'll realize that transforming the content you have (information from os.listdir) into presentation in HTML is a pain in the neck.

You can add Jinja templates to this to separate content from presentation.

Finally, you'll notice that you've started to build Django the hard way. Stop. Learn Django. You'll see that it's still "programming nuts and bolts". It doesn't "conceal" or "abstract" much away from the web server development experience. It just saves you from reinventing the wheel.

S.Lott
Nice, incremental way of getting something, apparently complicated, done.
Ionuț G. Stan
All right, all right, I'll switch. mod_wsgi here I come. But to animate the tree view will still require some javascript in the rendered page, won't it?
John Pirie
Thanks for the additional edits. I'll surely get to Django, next week or next quarter. Have to go through one tough exercise to appreciate the value it adds though.
John Pirie
Since "animate the tree view" can mean -- well -- anything, it's impossible to determine if you need JS or not. I recommend getting as much done as possible without JS. Later, you can learn about JSON and Web Services.
S.Lott
+1  A: 

If you want to make interactive browser, you have to learn JS and ajax.

If you want to build only browser based on links, python would be enough.

iyo
+1  A: 

The "totally cheesy" way:

python -m SimpleHTTPServer

This will serve up the files in the current directory at http://localhost:8000/

Ryan Ginstrom
A: 

set "Indexes" option to the directory in the apache config.

To learn how to build webapps in python, learn django.

erenon