Indy 10 Http 服务器示例
我需要 Indy 10 Http Server 的简单代码示例当请求(发布)只是显示它时 有 Indy 9 的样本吗? 谢谢
I need a simple code sample for Indy 10 Http Server When request (post) simply displays it
Is there an Indy 9 sample for this?
Thanks
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
双击表单以创建 OnCreate() 事件并激活服务器
IdHTTPServer1.Active := True;
返回表单,选择 HTTP Server 组件,并创建一个 OnCommandGet 事件
在此 OnCommandGet 事件(每当 GET/POST 发生时在子线程中调用)中,通过填充响应来处理请求。
根据您的 Delphi 版本,您可能还拥有添加IdContext到你的Uses子句
运行你的演示应用程序,然后启动浏览器到http://localhost,你应该得到一个回应。 (除非您有其他东西在端口 80 上侦听,在这种情况下您的演示应用程序将生成异常)
Double-click the form to create an OnCreate() event and activate the server
IdHTTPServer1.Active := True;
Back on the form, select the HTTP Server component, and create an OnCommandGet event
In this OnCommandGet event (which is called within a child thread whenever a GET/POST occurs), handle the request, by populating the response..
Depending on your Delphi version, you may also have to add IdContext to your Uses clause
Run your demo app and then launch a browser to http://localhost and you should get a response. (Unless you have something else listening on Port 80 in which case your demo app will generate an exception)
Indy 9 示例 仍然可以在 IndyProject 网站上使用,并包含一个 HTTPServer 演示项目。 印地10 Demo Playground 也是如此。
在 IdHTTPServer 中,Get 和 Post 命令本质上是相同的,并在 CommandGet 事件中处理。
The Indy 9 samples are still available on the IndyProject site and include an HTTPServer demo project. The Indy 10 Demo Playground does as well.
In IdHTTPServer, Get and Post commands are essentially treated the same and handled in the CommandGet event.