做一个客户端 - 服务器应用程序 [英] make a Client-Server application

查看:202
本文介绍了做一个客户端 - 服务器应用程序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我曾经在同一台电脑上建立网路应用程式,但如果伺服器和用户端不在同一台电脑上,我们如何存取网页?

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 ?

我的意思是,例如我有一个html表单和一个按钮ok:
如果服务器和客户端在同一台计算机,在action =我们把localhost / file.py,但如果服务器和客户端不在同一台计算机上怎么做?因为客户端不能在他的webbrower(url)中有localhost。

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

推荐答案

您的脚本应该作为CGI脚本由Web服务器设置环境变量,如REMOTE_ADDR,REQUEST_METHOD ...

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.

这就是为什么你得到KeyError。

That's why you get the KeyError.

这篇关于做一个客户端 - 服务器应用程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆