在本地主机中显示图像 [英] Displaying an image in a local host

查看:59
本文介绍了在本地主机中显示图像的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

你好,



我用snorkel API来开发嵌入式网络服务器,允许客户通过POST表单提交一些信息并且基于该信息,生成了QR码。

现在问题是我无法显示QR码(保存为.jpg图像)。



Snorkel API使用提供基于HTTP的UI,用于管理我正在尝试提供的服务。 (它提供了一个基于HTTP的UI作为主要的最终用户界面。)



因此,每当我运行我的C ++嵌入式Web服务器(浮潜)时,我打开互联网浏览器并写入http:// localhost:80以获得最终用户界面。



一切正常,除了显示图像,我认为是一个编程错误,我找不到。



这是代码,如果有人可以提供帮助,我真的很感激:



hello,

I've used "snorkel API" to develop an embedded web-server which allows the client to submit some information through a "POST form", and based on this information, a QR code has been generated.
Now the problem is that I cannot display the QR code (Which is saves as .jpg image).

The Snorkel API use provides an HTTP based UI to manage the service that I'm trying to provide. (it provides an HTTP based UI as the primary end-user interface).

So, whenever I run my C++ embedded web-server (snorkel), I open the internet explorer and write http://localhost:80 to get the end-user interface.

Everything is working just fine, except for displaying the image, which i think is a programming mistake, which i cannot find.

Here is the code, if someone can help, I'd really appreciate it:

#pragma hdrstop
#pragma argsused

#include <snorkel.h>
#include <tchar.h>
#include <stdio.h>
#include <stdlib.h>

call_status_t index_htm(snorkel_obj_t http,     /*read environment from this object */
			snorkel_obj_t outstream)  /* write data to the output stream   */
  {
   
   if (snorkel_printf (outstream, "<html><body><h2><img src=<c:\users\rania\documents\snorkel> width=178 height=178"
"</h2></body></html>\r\n")== SNORKEL_ERROR)
		 return HTTP_ERROR;

   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 = 80;
  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 number */
		port = atoi (argv[i + 1]);
		i++;
		break;
		default:
		syntax (argv[0]);
		break;
		}
	  }
   }

/*
 *
 * initialize API
 *
 */
 if (snorkel_init () != SNORKEL_SUCCESS)
  {
	perror ("could not initialize snorkel\n");
	//exit (1);
   }
/*
 *
 * create a server object
 *
 */
 http = snorkel_obj_create (snorkel_obj_server, 2,     /* number of handler threads to create */
								 "/Users/rania/Documents/Snorkel PRACTICE"       /* directory containing index.html     */);

  if (!http)
   {
	 perror ("could not create http server\n");
	 //exit (1);
   }

/*
 *
 * create a listener
 *
 */
 if (snorkel_obj_set (http,    /* server object */
					  snorkel_attrib_listener, /* attribute   */
					  port,    /* port number */
					  0 /* SSL support */ )
					  != SNORKEL_SUCCESS)
	  {
	   fprintf (stderr, "could not create listener\n");
	   snorkel_obj_destroy (http);
	   //exit (1);
	  }

 /*
  *
  * overload the URL index.html
  *
  */

 if (snorkel_obj_set (http,    /* server object */
					 snorkel_attrib_uri,      /* attribute type */
					 GET,     /* method */
					 "/index.html",   /* url */
					 contenttype_binary, index_htm) != SNORKEL_SUCCESS)
		 {
		   perror ("could not overload index.html");
		   snorkel_obj_destroy (http);
		   //exit (1);
		  }

 if (snorkel_obj_set(http, snorkel_attrib_ipvers, IPVERS_IPV4, SOCK_SET) != SNORKEL_SUCCESS)
		{
		  fprintf (stderr, "error could not set ip version\n");
		  //exit (1);
		 }

 /*
  *
  * start the server
  *
  */
  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);
	//exit (1);
	}

/*
 *
 * do something while server runs
 * as a separate thread
 *
 */
  fprintf (stderr, "\n[HTTP] started.\n\n"
					 "--hit enter to terminate--\n");
  fgets (szExit, sizeof (szExit), stdin);

  fprintf (stderr, "[HTTP] bye\n");

 /*
  *
  * graceful clean up
  *
  */
  snorkel_obj_destroy (http);
  exit (0);
  }







请,需要你的帮助。

最好的问候。




Please, need your help.
Best Regards.

推荐答案

这篇关于在本地主机中显示图像的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆