FRIHOSTFORUMSSEARCHFAQTOSBLOGSCOMPETITIONS
You are invited to Log in or Register a free Frihost Account!

Beneath The Surface

Created on Wed Oct 19, 2011 1:14 pm with 4 blog posts
Logging all things beneath the surface.

Now with publisher handler in Python with 0 comments on Mon Oct 31, 2011 10:34 am
In the previous post I set up a Python cgihandler. This post is about the publisher handler. This time you will need two files again:
    opel/.htaccess
    opel/vin.py

The .htaccess has:
Code:
AddHandler mod_python .py
PythonHandler mod_python.publisher
PythonDebug On
Options +MultiViews
MultiviewsMatch Handlers

And the Python code has:
Code:
#!/usr/bin/env python

import re
import cgi
import cgitb; cgitb.enable()  # for troubleshooting

...

def decode(req):
    req.content_type = "text/html"
    form = req.form
...
    # Send web page
    #
    req.write(content)

The decode function parses the form arguments given (if any) and generates the HTML content for the browser. You use this code through URL "http://.../opel/vin/decode". So, it's easy to add more functionality just by adding a function definition into vin.py.

The script vin.py decodes the Opel Vehicle Identification Number. You can try it here: http://www.kta.frihost.org/opel/vin/decode.

I import cgi for cgi.escape.
Up and running in server 4 in Python with 0 comments on Thu Oct 27, 2011 1:35 pm
I managed to have a python CGI environment up and running in server 4. The files I now have under public_html are:
    ptest/.htaccess
    ptest/environment.py

The .htaccess has:
Code:
AddHandler mod_python .py
PythonHandler mod_python.cgihandler
PythonDebug On
Options +MultiViews
MultiviewsMatch Handlers

I learned that I must have option MultiViews set and also have to set Handlers in directive MultiviewsMatch.

The environment.py has:
Code:
#!/usr/bin/env python

import os
import sys

env = ""
keys = os.environ.keys()
keys.sort()
for k in keys:
    env = env + "%s = %s</br>" % (k, os.environ[k])

print """Content-type: text/html; charset=iso-8859-1

<html>
<head>
<title>Environment</title>
<body>
Environment
<hr>
%s
<hr>
Python: %s
</body>
</html>""" % (env, sys.version)

With this setup I can request http://.../ptest/environment without the file extension, which is nice and clean.
Technology - Architecture - Aesthetics in Ad hoc with 0 comments on Thu Oct 20, 2011 1:07 pm
Nowadays a succesful product must embody these three. Just think about it, would you buy a gadget that does not have the tech? Or is not assuring? Or does not please the eye?

Apple products certainly have the technology and the aesthetics, but do they have the architecture to assure the developer? They certainly provide the ecosystem to build applications, but being a closed architecture, it is vulnerable to NIH syndrome and thus may one day become obsoleted by more alive architectures.

For example, VMWare is announcing Horizon Mobile, which allows centralized virtual phone provisioning with a selection of applications - for LG Android phones at least. Although this use case is targeted for the enterprise, we will see the consumer use cases soon. But remember that Apple has always denied running their OS on virtual hardware, so they won't be part of this game.
When to blog? in Ad hoc with 0 comments on Wed Oct 19, 2011 1:30 pm
Many things in world are beneath a surface. Occasionally the subconsciousness reveals the hidden surface to our thinking and we start to see through it. At these moments our mind has an opportunity to give a form and structure to the world beneath. It may be a very small matter for the general audience, but personally a great revelation. For me, this is the essence of a web log.
--> All blog posts (4)

FRIHOST HOME | FAQ | TOS | ABOUT US | CONTACT US | SITE MAP
© 2005-2011 Frihost, forums powered by phpBB.