hello
I'm trying to display an image file (.jpg) using the snorkel web-server, by using the GET method, but its not displaying the image.
all I get is a very small box with an X inside of it.
so, I was wondering do I need to use MIME or what shall I do to display my image?
here's my code:
#pragma hdrstop
#pragma argsused
#include <snorkel.h>
#include <tchar.h>
#include <stdio.h>
#include <stdlib.h>
call_status_t
view_image(snorkel_obj_t http,
snorkel_obj_t outstream)
{
snorkel_printf (outstream, "<html><body><img src = QR4.jpg>"
"</body></html>\r\n");
return HTTP_SUCCESS;
}
void syntax (char *pszProg)
{
fprintf (stderr, "syntax error:\n");
fprintf (stderr, "%s [-p <port>]\n", pszProg);
exit (1);
}
void main (int argc, char *argv[])
{
int i = 1;
int port = 8090;
snorkel_obj_t http = 0;
char szExit[10];
for (; i < argc; i++)
{
if (argv[i][0] == '-' || argv[i][0] == '/')
{
char carg = argv[i][1];
switch (carg)
{
case 'p':
port = atoi (argv[i + 1]);
i++;
break;
default:
syntax (argv[0]);
break;
}
}
}
if (snorkel_init () != SNORKEL_SUCCESS)
{
perror ("could not initialize snorkel\n");
}
http = snorkel_obj_create (snorkel_obj_server, 5, NULL);
if (!http)
{
perror ("could not create http server\n");
}
if (snorkel_obj_set (http,
snorkel_attrib_listener,
port,
0 )
!= SNORKEL_SUCCESS)
{
fprintf (stderr, "could not create listener\n");
snorkel_obj_destroy (http);
}
if (snorkel_obj_set (http, snorkel_attrib_uri, GET, "/index.html", contenttype_text, view_image) != SNORKEL_SUCCESS)
{
perror ("could not overload index.html");
snorkel_obj_destroy (http);
}
if (snorkel_obj_set(http, snorkel_attrib_ipvers, IPVERS_IPV4, SOCK_SET) != SNORKEL_SUCCESS)
{
fprintf (stderr, "error could not set ip version\n");
}
snorkel_obj_set(http, snorkel_attrib_mime, "jpg",
"image/jpeg",
contenttype_text,
view_image);
fprintf (stderr, "\n\n[HTTP] starting embedded server\n");
if (snorkel_obj_start (http) != SNORKEL_SUCCESS)
{
perror ("could not start server\n");
snorkel_obj_destroy (http);
}
fprintf (stderr, "\n[HTTP] started.\n\n"
"--hit enter to terminate--\n");
fgets (szExit, sizeof (szExit), stdin);
fprintf (stderr, "[HTTP] good bye\n");
snorkel_obj_destroy (http);
exit (0);
}
can you please help me:confused:
Best Regards.
Rania