Hi all,
I've been using .ini files for some time now to configure my software, but it's becoming quite annoying to work with. I'd like to have something graphical with drop-down lists, radio buttons and checkboxes. And ideally I would like it to be interactive, and remote. That would allow me to debug different settings interactively and when working fullscreen I can control it from another system within the LAN.
One approach I've been looking at is to use an embedded HTTP server. This way I could just open a browser, connect to my software acting like a web server, see the current configuration, and change it with the click of a button. The problem is, web technology is as scary to me as shader assembly is to a web developer. :surrender
So does anyone have an idea how to get started with this? I'd really like to keep it lean (it only needs to serve one page to one user) but I'd rather not re-invent the wheel either (some people suggested to write my own server and generate the pages). If you know of any tools tailored towards my goal that would be awesome.
Thanks,
Nicolas
Web page for software configuration.
Started by Nick, Jan 22 2008 03:31 PM
9 replies to this topic
#1
Posted 22 January 2008 - 03:31 PM
#2
Posted 22 January 2008 - 06:52 PM
Actually, I've found embedding an HTTP server to be incredibly easy. I've used shttpd in the past and it worked great. It's just a few C files and some callback functions to handle requests.
Nils mentioned a coworker doing an implementation from scratch in a day when I asked about the topic a few years ago.
I also made some Lua bindings to shttpd that really simplified the process. I used it for peeking/poking memory with a web browser in a running embedded system as well as for configuration. I used AJAX to get dynamic updates of some data too.
URL="http://www.keplerproject.org/"]Kepler[/URL] and Xavante may be worth looking into if you are found of Lua.
I'd encourage you to go this route. I did it to force myself to learn some web programming and found it beneficial.
Nils mentioned a coworker doing an implementation from scratch in a day when I asked about the topic a few years ago.
I also made some Lua bindings to shttpd that really simplified the process. I used it for peeking/poking memory with a web browser in a running embedded system as well as for configuration. I used AJAX to get dynamic updates of some data too.
URL="http://www.keplerproject.org/"]Kepler[/URL] and Xavante may be worth looking into if you are found of Lua.
I'd encourage you to go this route. I did it to force myself to learn some web programming and found it beneficial.
#3
Posted 23 January 2008 - 09:48 AM
Thanks, I'll look at shttpd and Lua.
I'm still clueless how to make the "Hello World" case for this though. Even a page with one checkbox that controls a boolean in my C++ code would be an enormous breakthrough for me. Can anyone give me a hand with that or point me in the right direction of exactly what needs to be done? :worthy:
I think I can take it from that point, but I feel like a 13 year old newbie when it comes to seeing how the essential pieces fit together...
I'm still clueless how to make the "Hello World" case for this though. Even a page with one checkbox that controls a boolean in my C++ code would be an enormous breakthrough for me. Can anyone give me a hand with that or point me in the right direction of exactly what needs to be done? :worthy:
I think I can take it from that point, but I feel like a 13 year old newbie when it comes to seeing how the essential pieces fit together...
#4
Posted 23 January 2008 - 12:16 PM
Hi!
I made a simple HTTP server a few years ago just for fun, I'll see tonight (in about 12 hours from now)when I get home if I still have the code in the case nobody had already helped you in the mean time.
Moulinex
I made a simple HTTP server a few years ago just for fun, I'll see tonight (in about 12 hours from now)when I get home if I still have the code in the case nobody had already helped you in the mean time.
Moulinex
#5
Posted 23 January 2008 - 03:41 PM
The following C program listing uses shttpd to serve a page with a checkbox and submit button that will set an internal boolean value:
#include <stdlib.h>
#include <string.h>
#include "shttpd.h"
enum BOOL { FALSE = 0, TRUE };
typedef enum BOOL BOOL;
static void
show_page(struct shttpd_arg *arg)
{
BOOL *data = arg->user_data;
/* create our simple page */
shttpd_printf(arg, "%s",
"HTTP/1.1 200 OK\r\nContent-Type: text/html\r\n\r\n"
"<html><body>");
shttpd_printf(arg, "<form method=\"GET\" action=\"/data\">"
"<input type=\"checkbox\" name=\"data\" %s/>"
"<input type=\"submit\"/>"
"</form>", *data ? "checked=\"1\"" : "");
shttpd_printf(arg, "%s", "</body></html>");
/*
* Tell shttpd that we are done (it would continue to callback for larger
* pages that don't fit in the output buffer)
*/
arg->flags |= SHTTPD_END_OF_OUTPUT;
}
static void
submit_data(struct shttpd_arg *arg)
{
BOOL *data = arg->user_data;
const char *query_string = shttpd_get_env(arg, "QUERY_STRING");
/* only checked boxes show up in the query string */
*data = (0 < strlen(query_string));
/* redisplay the page */
show_page(arg);
}
int
main(int argc, char *argv[])
{
struct shttpd_ctx *context = NULL;
BOOL data = FALSE; /* we'll set this boolean with a checkbox */
/* create an HTTP server */
context = shttpd_init(NULL, NULL);
/*
* Setup a callback for showing your page. It defaults to serving a page
* from the file system if you don't register the URI.
*/
shttpd_register_uri(context, "/", &show_page, (void *) &data);
shttpd_register_uri(context, "/index.html", &show_page, (void *) &data);
/*
* Setup a callback for checking our boolean value
*/
shttpd_register_uri(context, "/data", &submit_data, (void *) &data);
/* listen for connections on port 8080 */
(void) shttpd_listen(context, 8080, FALSE);
/* poll for connections */
for (;;) {
shttpd_poll(context, 1000);
if (data != prev_data) {
printf("data = %d\n", data);
prev_data = data;
}
}
/* cleanup */
shttpd_fini(context);
return EXIT_SUCCESS;
}
#6
Posted 23 January 2008 - 06:54 PM
In couple of game projects I worked in, there was a C# GUI to control the game remotely. I don't know which protocol was used for the communication though.
Game Developer's Wonderland - GD Blog
#8
Posted 23 January 2008 - 08:09 PM
I've had a go at some web development using Visual Web Developer Express, it's fairly simple to get to grips with. You can do all the coding in c# and there are plenty of controls to develop good user interfaces with. It also uses the standard Visual Studio IDE, albeit with some minor alterations for web stuff.
Hope I'm answering the right question... ;-)
Hope I'm answering the right question... ;-)
#9
Posted 24 January 2008 - 01:51 AM
Moulinex said:
Hi!
I made a simple HTTP server a few years ago just for fun, I'll see tonight (in about 12 hours from now)when I get home if I still have the code in the case nobody had already helped you in the mean time.
Moulinex
I made a simple HTTP server a few years ago just for fun, I'll see tonight (in about 12 hours from now)when I get home if I still have the code in the case nobody had already helped you in the mean time.
Moulinex
:blush: Sorry but I just can't find it...
Moulinex
#10
Posted 24 January 2008 - 01:33 PM
Thanks a lot monjardin! :yes:
1 user(s) are reading this topic
0 members, 1 guests, 0 anonymous users












