Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Python / google app engine self request domain

Tags:

python

I know that the google app engine come with the self.request for url and the path in the python platform.

What I wanted to know is that did it come with anything to return only the domain name?

This is because sometime in the localhost, mywebapps.appspot.com and www.mywebapps.com will have different kind of behavior.

Or is there any python code I can referring to?

like image 512
Peter Avatar asked Dec 03 '25 00:12

Peter


1 Answers

Google app engine uses the CGI standard, you can use Host header in request from within the application code and respond accordingly.

How to access Host will depend on the web framework e.g webapp and django may differ in details, but as it is CGI you can just access os.environ from anywhere e.g.

import os
logging.debug("Host: %s"%os.environ['HTTP_HOST'])
like image 75
Anurag Uniyal Avatar answered Dec 05 '25 15:12

Anurag Uniyal



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!