finding domain name

Tino Wildenhain tino at wildenhain.de
Tue Sep 23 12:47:33 EDT 2008


Hi,

Bobby Roberts wrote:
> On Sep 23, 9:10 am, Tino Wildenhain <t... at wildenhain.de> wrote:
>> Bobby Roberts wrote:
>>>> Depends on the technology/web framework. If you use WSGI, you should use
>>>> something like:
>>>> host_name = environ.get("HTTP_HOST", None) or environ["SERVER_NAME"]
>>>> -- Gerhard
>>> Yeah i already tried environ("SERVER_NAME") but get a key error when i
>>> do.
>> You could output the whole environ to see what you get and how it is called.
...

> evidently the environ dictionary is off limits on our server. It can't
> be that tough in python to get the current complete url being viewed.
> It's a snap in asp(which is my background).

Its a snap in all python based web apps I ever saw. You didn't tell us
what you actually using so we can't say. Also there is no notation
of "url beeing viewed" in HTTP if you are looking from server's point of
view. There is a request for an URI and a host where the request is
directed at then then the server decides to publish a resource based
on whatever rules. If that publishing results in a call to your python
script (or the script itself is the server) then you would deal with
whatever interface API you decided to use gives you.

Ah and last not least you can even use python in ASP (look for scripting
host) but's not a route to take these days :-) (You really want no
inline code but a decent templating engine like PageTemplates (TAL))

Tino
-------------- next part --------------
A non-text attachment was scrubbed...
Name: smime.p7s
Type: application/x-pkcs7-signature
Size: 3241 bytes
Desc: S/MIME Cryptographic Signature
URL: <http://mail.python.org/pipermail/python-list/attachments/20080923/6370c19a/attachment-0001.bin>


More information about the Python-list mailing list