http://blog.csdn.net/chelen_jak/article/details/50203809
转自:
http://3699119.blog.163.com/blog/static/167075351201373024054586/
- unit main;
-
- interface
-
- uses
- Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
- Dialogs, IdBaseComponent,IdContext ,IdComponent, IdCustomTCPServer, IdCustomHTTPServer,
- IdHTTPServer, StdCtrls;
-
- type
- TForm_main = class(TForm)
- IdHTTPServer1: TIdHTTPServer;
- Button_StartServer: TButton;
- Edit_Port: TEdit;
- Label1: TLabel;
- Label2: TLabel;
- Edit_Ip: TEdit;
- Button_stop: TButton;
- Label3: TLabel;
- Edit_RootDir: TEdit;
- Edit_index: TEdit;
- Label4: TLabel;
- procedure Button_StartServerClick(Sender: TObject);
- procedure Button_stopClick(Sender: TObject);
- procedure IdHTTPServer1CommandGet(AContext: TIdContext;
- ARequestInfo: TIdHTTPRequestInfo; AResponseInfo: TIdHTTPResponseInfo);
- private
-
- public
-
- end;
-
- var
- Form_main: TForm_main;
-
- implementation
- var
- RootDir:string;
- URL:string;
- {$R *.dfm}
-
- procedure TForm_main.Button_StartServerClick(Sender: TObject);
- begin
- try
- IdHTTPServer1.Bindings.Clear;
-
- IdHTTPServer1.DefaultPort:=strtoint(trim(edit_port.Text));
- IdHTTPServer1.Bindings.Add.IP := trim(edit_Ip.Text);
-
- IdHTTPServer1.Active := True;
- except
- showmessage(‘启动失败!‘);
- end;
- RootDir:=trim(edit_rootDir.Text);
- URL:=‘http://‘+trim(edit_Ip.Text)+trim(edit_port.Text)+‘/‘;
- end;
-
- procedure TForm_main.Button_stopClick(Sender: TObject);
- begin
- IdHTTPServer1.Active := false;
- end;
-
- procedure TForm_main.IdHTTPServer1CommandGet(AContext: TIdContext;
- ARequestInfo: TIdHTTPRequestInfo; AResponseInfo: TIdHTTPResponseInfo);
- var
- LFilename: string;
- LPathname: string;
- zhongwen:string;
- begin
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- end;
-
- end.
delphi idhttpsever
原文:http://www.cnblogs.com/delphi-xe5/p/5459682.html