Search code examples
jsonweb2pypythonanywhere

Web2Py Application - Server IP variable instead of: 192.168.178.46:8000, 192.168.178.53:8000 and pythonanywhere


When starting up web2py locally I can select an IP address and port e.g. 192.168.178.46:8000 or 192.168.178.53:8000 etc.

When using Web2Py with json, currently I am using the hard coded IP address:

d3.json("http://192.168.178.46:8000/web2pyappname/default/
rt_batt_data_json_xml_hmtl_dViz.json")  
   .then(function(json_array){ .....

In case starting up different, the IP address this code has to be changed.

Is there a variable ( etc) that retrieves the IP address and can be used instead of (to be put directly in the weblink)?

The same, when using/deploying on pythonanywhere (the current problem)?

https://user_subdomain.pythonanywhere.com/admin/default
  /design/web2pyappname

Whilst navigating through the web2py app works fine, I already get an error message when trying to access a db-table invalid view (default/rt_batt_data_json_xml_hmtl_dViz.json)

Or is this done in a different way as a service (which then already should be used when developing locally)?

In case its already answered in detail, a weblink has to fine for me.


Solution

  • You should be able to use a relative URL:

    d3.json("/web2pyappname/default/rt_batt_data_json_xml_hmtl_dViz.json")