Forums

Domain url when starting a script locally (web2py)

I have a script running in the background using web2py environment (model). However, it seems that the script is run locally, so that means that web2py sees the URL also local (http://127.0.0.1). If I create a full absolute link through a website request the URL points to my CNAME domain, but the scheduled script generates the same link with local address (i.e. 127.0.0.1).

I'm new in this area, so just wanted to confirm that this is expected (as I assume), when script is run internally.

I decided to define the domain manually and add it to each URL that I generate with absolute path: URL('user',args='login',scheme="http",host="domain.com").

However, I would still like to know I can get the domain programmatically within the environment.

The idea of a domain for a running script has no meaning. It's just a script. A PythonAnywhere user can have multiple domains configured. How would a script tell which one you meant?