make a Client-Server application

杀马特。学长 韩版系。学妹 提交于 2019-12-13 04:19:10

问题


I used to create web app in the same computer, but if the server and the client is not in the same computer, how can we access to the web page ?

I mean, for example I have an html form and a button "ok" : If the server and the client are in the same computer, in action = " " we put localhost/file.py , but if the server and the client are not in the same computer how to do this ? Because the client can't to have localhost in his webbrower (url).


回答1:


Your script is supposed to be run as a CGI script by a web-server, which sets environment variables like REMOTE_ADDR, REQUEST_METHOD ...

You are running the script by yourself, and this environment variable are not available.

That's why you get the KeyError.




回答2:


The "action" part of a form is an url, and If you don't specify the scheme://host:port part of the URL, the client will resolve it has the current page one. IOW: just put the path part of your script's URL and you'll be fine. FWIW hardcoding the scheme://host:port of your URLs is an antipattern, as you just found out.



来源:https://stackoverflow.com/questions/24890739/make-a-client-server-application

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!