We don’t allow questions seeking recommendations for software libraries, tutorials, tools, books, or other off-site resources. You can edit the question so it can be answered with facts and citations.
Closed 7 years ago.
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
接受
或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
发布评论
评论(7)
假设您的应用程序将作为 apache 或其他 HTTP 服务器的 CGI 执行,您只需将 HTTP 标头和页面内容打印到 stdout 即可。
预期的最小标题是:(
不要忘记双 \r\n)
然后编写您的页面。
Assuming your application will be executed as a CGI of apache or another HTTP server, you only need to print the HTTP headers and the content of the page to stdout.
The minimal headers expected are:
(do not forget the double \r\n)
then write your page.
C?不太合适的语言。
但是,有人用它做了 CMS,称为 Tokyopromenade,开源
http://1978th.net/tokyopromenade/
只是供你参考
C? Not so suitable language for that.
But, someone did CMS with that, called Tokyopromenade, Opensource
http://1978th.net/tokyopromenade/
Just for your information
要使用 C 生成 (D|X)HTML,您必须编写 CGI 程序。 CGI 程序应在输出 HTML 之前输出
Content-type: text/html
或等效内容。之后,您可以将程序上传到
cgi-bin/
或等效目录。请记住在文件上设置执行位。For using C to generate (D|X)HTML, you will have to write CGI programs. CGI programs should output the
Content-type: text/html
or equivalent before HTML is output.After that, you can upload the program to the
cgi-bin/
or equivalent directory. Remember to set the execution bit on the file.让您的 C 程序先将
Content-type: text/html\n\n
写入 stdout,然后您就可以生成您想要的任何 HTML。空行很关键!Have your C program write
Content-type: text/html\n\n
to stdout before anything else, and you can then generate whatever HTML you wish. The empty line is critical!“DHTML”主要用于描述客户端功能,您可以使用 Javascript 来实现这一点。
但如果你指的是动态网页(服务器端功能),并且必须使用 C,则可以使用 CGI(通用网关接口,RFC3875):
http://hoohoo.ncsa.illinois.edu/cgi/primer.html
但是,使用 C 语言编写网页并不是一个好的选择。最好使用 Python 或 Ruby 这样的脚本语言,然后研究该语言对 CGI 的支持,或者使用 Ruby on Rails 这样的框架。
"DHTML" is mostly used to describe client-side functionality, and you use Javascript for that.
But if you mean dynamic web pages (server-side functionality), and you must use C, you can use CGI (Common Gateway Interface, RFC3875):
http://hoohoo.ncsa.illinois.edu/cgi/primer.html
However, using C for web pages is not a good choice. It would be better to use a scripting language like Python or Ruby, and either study the CGI support in that language or go for a framework like Ruby on Rails.
要使用 C 创建动态网页,您可以采用多种方法(这不是详尽的列表):
您使用 CGI,创建动态网页的旧标准。其工作原理是,对于您站点的每个请求,您的网络服务器都会创建一个新进程,调用您的程序(使用环境变量和 stdin 将有关请求的信息传递给您的程序),并提供输出从您的程序到网络浏览器。正如其他回复所指出的,CGI 要求您的程序向浏览器指定 HTTP 响应标头。
如果您在开发网页时出于性能原因而有兴趣使用 C(这有点疯狂),那么 CGI 显然不是一个选择。如果您是一个受虐狂,您可能应该考虑与 FastCGI 链接或创建 Apache 模块。事实上,既然你这么喜欢痛苦,你不妨从 thttpd 开始,然后插入你的 。
祝你好运。您也可以考虑去看心理医生。
To create dynamic webpages using C, there are a couple of ways you can go about this (this is not an exhaustive list):
You use CGI, an old standard for creating dynamic webpages. The way this works is that for each request to your site, your webserver creates a new process, invokes your program (passing information about the request to your program using environmental variables and
stdin
), and feeds the output from your program to the web browser. As other replies have noted, CGI requires your program to specify the HTTP response headers to the browser.If you're interesting in using C for performance reasons when developing webpages (this is sort of diving into insanity), CGI clearly isn't an option. If you're this much of a masochist, you should probably look into linking with FastCGI or creating an Apache module. In fact, since you like pain this much, you might as well just start with thttpd and insert your code where needed.
Good luck. You might also consider seeing a shrink.
在 stackoverflow 上搜索“C library for web applications”,它有一些很好的答案。
我还没有尝试过,也许有人会觉得它有用:klone。
它是一个用于构建独立 Web 服务器和 html 模板的框架
嵌入式 C .
Search "C library for web applications" here on stackoverflow, it has some good answers.
I haven't tried it, maybe someone would find it usefull: klone.
It is a framework for building standalone web serververs and html templating with
embedded C.