apt install nc寫入web.c

vim web.c

#include <stdio.h>int main(){ void html(char *txt); printf(&#34;HTTP/1.1 200 OK/r/n&#34;); printf(&#34;server:" />

国产成人精品无码青草_亚洲国产美女精品久久久久∴_欧美人与鲁交大毛片免费_国产果冻豆传媒麻婆精东

15158846557 在線咨詢 在線咨詢
15158846557 在線咨詢
所在位置: 首頁 > 營銷資訊 > 網(wǎng)站運營 > 如何用 c 語言搭建一個簡單的網(wǎng)站?

如何用 c 語言搭建一個簡單的網(wǎng)站?

時間:2023-12-03 12:00:01 | 來源:網(wǎng)站運營

時間:2023-12-03 12:00:01 來源:網(wǎng)站運營

如何用 c 語言搭建一個簡單的網(wǎng)站?:安裝nc

apt install nc寫入web.c

vim web.c

#include <stdio.h>int main(){ void html(char *txt); printf("HTTP/1.1 200 OK/r/n"); printf("server: clang web 1.1/r/n"); printf("/r/n"); html("hello clang web"); html("test clang web"); printf("/r/n/r/n"); return 0;}void html(char *txt){printf("<p>%s</p>",txt);}直接gcc web.c -o web編譯

然后運行

nc -l -p 8080 -e "./web"訪問127.0.0.1:8080可以顯示

hello clang web
test clang web
要一直后臺運行,寫一個腳本

vim web.sh

while truedonc -l -p 8080 -e "./web"done運行

sh web.sh這是Linux下的方法,Windows下同理。

關(guān)鍵詞:簡單,語言

74
73
25
news

版權(quán)所有? 億企邦 1997-2025 保留一切法律許可權(quán)利。

為了最佳展示效果,本站不支持IE9及以下版本的瀏覽器,建議您使用谷歌Chrome瀏覽器。 點擊下載Chrome瀏覽器
關(guān)閉