Autor Beitrag
pmw
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 65



BeitragVerfasst: Fr 23.05.03 14:58 
Hallo!

Wie kann ich einen einfachen HTML Server programmieren, der bei der Eingabe der IP im Browser eine HTML-Seite anzeigt. Wie kann man das realisieren?

Viele Grüße
Martin Winandy
BungeeBug
ontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic starofftopic star
Beiträge: 901



BeitragVerfasst: Fr 23.05.03 15:57 
Hi,
Am einfachsten ist dann wohl das benutzen der Indy-Kompenenten (IdHTTPServ). Der Rest ist dann nur noch Eingenschaftswerte setzten.

MfG BungeeBug
pmw Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 65



BeitragVerfasst: Fr 23.05.03 16:54 
Hallo!

Danke für den Hinweis! Es klappt einwandfrei, wenn ich die Komponente auf ein Form-Blatt setzte. Leider will die Komponente nicht ohne Formblatt arbeiten. :(

ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
program ZeitServer;

uses
  IdHTTPServer;

{$R *.res}

var
  HTTPServer: TIdHTTPServer;

begin

   HTTPServer := TIdHTTPServer.Create(self); // <- Fehlermeldung: Undefinierter Bezeichner 'Self'

   with HTTPServer do begin

      Name := 'Server';
      Active := True;
      Bindings.Add;
      Bindings.Items[0].IP := '0.0.0.0';
      Bindings.Items[0].Port := 44;
      DefaultPort := 44;
      Greeting.Text.CommaText := '<body><h1>Herzlich Willkommen!</h1>Mein 1. Server ...</body>';
      Greeting.TextCode := 'text/html';

   end;

end.


Wie kann ich die Indy-Komponente auch ohne Form-Blatt nutzen?

Viele Grüße
Martin Winandy
BungeeBug
ontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic starofftopic star
Beiträge: 901



BeitragVerfasst: Fr 23.05.03 17:10 
dann versuch mal
ausblenden Delphi-Quelltext
1:
nil					


MfG BungeeBug
pmw Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 65



BeitragVerfasst: Fr 23.05.03 17:16 
Dann stürtzt das Programm leider direkt beim Programmstart ab :(

user defined image

Edit: Ich habe den Fehler gefunden! Active := True muss an's Ende.

----------------------------

Ich habe jetzt leider ein weiteres Problem: Das Programm beendet sich jetzt immer sosort, wie kann ich das Verhindern?

Geht das vielleicht eleganter als mit:
ausblenden Delphi-Quelltext
1:
2:
3:
4:
   while 1=1 do begin
      sleep(10);
      Application.ProcessMessages;
   end;


----------------------------

Noch eine Frage: Wie kann ich auf Eingaben wie z.B.: "127.0.0.1:44/seite1" reagieren?

Viele Grüße
Martin Winandy
obbschtkuche
Gast
Erhaltene Danke: 1



BeitragVerfasst: Fr 23.05.03 19:05 
pmw Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 65



BeitragVerfasst: Fr 23.05.03 19:35 
@obbschtkuche: Danke für die Antwort!

Damit wären alle außer die letzte Frage geklärt.
Zitat:
Noch eine Frage: Wie kann ich auf Eingaben wie z.B.: "127.0.0.1:44/seite1" reagieren?
pmw Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 65



BeitragVerfasst: Mo 26.05.03 19:46 
Weiß wirklich keiner weiter? :(
obbschtkuche
Gast
Erhaltene Danke: 1



BeitragVerfasst: Mo 26.05.03 20:03 
Hmmm. Hast du schonmal auf der Indyhomepage geguckt? (müsste in einer HTML-Datei, die bei den Demos dabei ist stehen)
matze
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 4613
Erhaltene Danke: 24

XP home, prof
Delphi 2009 Prof,
BeitragVerfasst: Di 27.05.03 17:07 
ich glaube du musst in einem ereignis des browsers das machen.

am besten die Demos bei INDY saugen und guggen !

_________________
In the beginning was the word.
And the word was content-type: text/plain.
pmw Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 65



BeitragVerfasst: Mi 04.06.03 18:36 
Hallo!

Ich habe mir die Demos angeschaut, aber leider weiß ich immer noch nicht, wie ich die Prozedur zur Laufzeit zuweisen kann :(
matze
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 4613
Erhaltene Danke: 24

XP home, prof
Delphi 2009 Prof,
BeitragVerfasst: Sa 07.06.03 12:40 
dazu musst du die prozedure wie eine ereignisbehandlung deklarieren !

_________________
In the beginning was the word.
And the word was content-type: text/plain.
pmw Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 65



BeitragVerfasst: So 08.06.03 09:53 
Zitat:
dazu musst du die prozedure wie eine ereignisbehandlung deklarieren


Wie mache ich das?
matze
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 4613
Erhaltene Danke: 24

XP home, prof
Delphi 2009 Prof,
BeitragVerfasst: So 15.06.03 13:03 
die procedure muss so aussehen:
ausblenden Delphi-Quelltext
1:
2:
3:
4:
procedure TForm1.blabla(Sender: TObject);
begin
   // Hier der Code
end;


die procedure musst du dann noch als public deklarieren. das machst du ganz oben im quelltext unter public
ausblenden Delphi-Quelltext
1:
 procedure blabla(Sender: TObject);					

_________________
In the beginning was the word.
And the word was content-type: text/plain.
pmw Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 65



BeitragVerfasst: So 15.06.03 20:03 
Ich habe aber keine Forms in meinem Programm. :cry: Deshalb exestiert auch kein TForm1. Geht das auch ohne Formblätter?
matze
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 4613
Erhaltene Danke: 24

XP home, prof
Delphi 2009 Prof,
BeitragVerfasst: Mo 16.06.03 08:22 
weiss ich nciht. probiers aus !

_________________
In the beginning was the word.
And the word was content-type: text/plain.