make a Client-Server application

2019-08-31 17:19发布

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).

2条回答
手持菜刀,她持情操
2楼-- · 2019-08-31 18:14

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.

查看更多
劳资没心,怎么记你
3楼-- · 2019-08-31 18:14

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.

查看更多
登录 后发表回答