User Tools

Site Tools


tutorials:http_server

This is an old revision of the document!


Getting started with GroIMPs HTTP-server

GroIMP comes with an basic HTTP server that allows users to open projects from a given path. The server can also manage basic additional input and the return of values to the http client.

In the following a brief start for this is given.

Starting the Server and Running a first Model

To start the server in GroIMP go on the main menu on Net/Open Http Server and select a port in the upcoming popup. This port is not specifically important, lets for now just use the default port suggested:“58080” (if you have another service running on this port just choose an other).

// import other compiled files (.rgg, .java, .xl) without subdirectory path.
import parameters.*;
 
import de.grogra.imp.net.*;
/***
 
A simple exampel of using the GroIMP HTTP server
 
http://localhost:58080/open?Documents/teaching/tuti/hallo_server.gsz&name=tim
 
java -jar platform.core-2.1.5-jar-with-dependencies.jar --headless -- -cmd "/http/server=58080"
 
 
 
***/
 
protected void startup()
{
	super.startup();
	HttpResponse resp = HttpResponse.get(workbench());
	if(resp!=null){
		println("test");
		runLater(resp);
	}
}
 
 
protected void run(Object info)
{
	HttpResponse resp = (HttpResponse)info; 
	StringBuffer buf = new StringBuffer();
	buf.append("Hi ");
	buf.append(resp.getRequest().getQuery().split("&")[1].split("=")[1]);
	buf.append(", whats up ");
	resp.setContent("text/text","UTF-8",buf.toString());
	resp.send(true);
	closeWorkbench();
}

Starting the server headless

GroIMP allows users to define which of its are suppose to be executed as an commandline parameter. This allows us to start the http server headless on a port of our linking:

java -jar core.jar --headless -- -cmd "/http/server=58080"
tutorials/http_server.1733124774.txt.gz · Last modified: 2024/12/02 08:32 by tim