Forums

http://127.0.0.1:xxxx/ issue

I have a function to run a calculation program and output a 3D graph which will automatically pop up in the browser. I am wondering if I deploy this python program inside my django view.py and deploy in pythonanyhwere server, will it do the same behavior? (i.e. when user click run this calculation, after it's done, the 3D graph will automaitcally popup in a new window/tab of the browser.

If it assumes running on the same machine as browser it won't work. Django on PythonAnywhere is running on remote server, not on local machine.

On the other hand I know nothing about your code, so maybe it's just rendering the view normal way.

In local machine, the model code will output a html kind of graph auto-opened in browser, with web address like "http://127.0.0.1:63792/"

That will not work on PythonAnywhere. See if there's an option for the software to write to a file.

write to a file is a solution. How to write the graph html to a django project folder in pythonanywhere server, and then automatically render it in a new web page or tab of user's local machine browser, without additional clicks?

You cannot control the user's machine from PythonAnywhere - it would be a huge security problem if random web sites could start programs on your computer.

Your best bet for the saving and serving would be to save the page to a folder that you are serving with the static files feature: https://help.pythonanywhere.com/pages/StaticFiles/

you mean save the graph html to a folder in static files, and then pickup it and render it in the django web page?

No, just save it to a static files folder and serve it from there.