oldteacher
Active member
Is there a way to change the port of http server dynamically with scripting?
Would be very useful to avoid conflicts.
Would be very useful to avoid conflicts.
procedure StartMyHTTPServer(portStr: String);
var
portNum: integer;
begin
StopHTTPServer;
ShowMessage("SelectedPort = " + portStr); // debug
portNum := StrToIntDef(portStr, 8142);
StartHTTPServer(portNum);
ShowMessage("Server started on port " + IntToStr(portNum));
end;
procedure StopMyHTTPServer;
begin
StopHTTPServer;
end;
<html>
<label for="portSelect">Choose Port:</label>
<select id="portSelect">
<option value="8080">8080</option>
<option value="8142" selected>8142</option>
<option value="9000">9000</option>
<option value="10000">10000</option>
</select>
<!-- Start...
I think we have a miscommunication.Sure, you can do that with HEScript. There is a code sample here about how to do it:
![]()
PHP Settings - External HTTP Server - ExeOutput for PHP
Learn how to configure and use an external HTTP server in your ExeOutput for PHP application, allowing access from a web browser.www.exeoutput.com
procedure StartMyHTTPServer;
var
portStr: string;
portNum: integer;
begin
portStr := GetGlobalVar('SelectedPort', '8142');
portNum := StrToIntDef(portStr, 8142);
StartHTTPServer(portNum);
ShowMessage('Server started on port ' + IntToStr(portNum));
end;
procedure StopMyHTTPServer;
begin
StopHTTPServer;
ShowMessage('Server stopped.');
end;
procedure StartMyHTTPServer;
var
portStr: string;
portNum: integer;
begin
// Read the port number from a global variable set by JavaScript
portStr := GetGlobalVar('SelectedPort', '8142');
portNum := StrToIntDef(portStr, 8142);
StartHTTPServer(portNum);
ShowMessage('Server started on port ' + IntToStr(portNum));
end;
procedure StopMyHTTPServer;
begin
StopHTTPServer;
ShowMessage('Server stopped.');
end;
procedure StartMyHTTPServer;
var
portStr: string;
portNum: integer;
begin
portStr := GetGlobalVar('SelectedPort', '8142');
ShowMessage('SelectedPort = "' + portStr + '"'); // debug
portNum := StrToIntDef(portStr, 8142);
StartHTTPServer(portNum);
ShowMessage('Server started on port ' + IntToStr(portNum));
end;
procedure StartMyHTTPServer;
var
portStr: string;
portNum: integer;
begin
portStr := GetGlobalVar("SelectedPort", "8142");
ShowMessage("SelectedPort = " + portStr); // debug
portNum := StrToIntDef(portStr, 8142);
StartHTTPServer(portNum);
ShowMessage("Server started on port " + IntToStr(portNum));
end;
Dang it, I did not catch that either. Thank you!My bad, it's the " quote and not the '.
I hate to keep bugging you, but is this possible to do? Or am I spinning my wheels and going nowhere?We're trying to reproduce the issue here, I'll keep you in touch![]()
procedure StartMyHTTPServer(portStr: String);
var
portNum: integer;
begin
StopHTTPServer;
ShowMessage("SelectedPort = " + portStr); // debug
portNum := StrToIntDef(portStr, 8142);
StartHTTPServer(portNum);
ShowMessage("Server started on port " + IntToStr(portNum));
end;
procedure StopMyHTTPServer;
begin
StopHTTPServer;
end;
<html>
<label for="portSelect">Choose Port:</label>
<select id="portSelect">
<option value="8080">8080</option>
<option value="8142" selected>8142</option>
<option value="9000">9000</option>
<option value="10000">10000</option>
</select>
<!-- Start button: build a hescript:// link dynamically -->
<button onclick="
var port = document.getElementById('portSelect').value;
location.href = 'hescript://UserMain.StartMyHTTPServer%7C' + encodeURIComponent(port);">
Start Server
</button>
<!-- Stop button: no parameters -->
<button onclick="location.href='hescript://UserMain.StopMyHTTPServer'">
Stop Server
</button>
</html>
We use essential cookies to make this site work, and optional cookies to enhance your experience.