時間:2023-12-03 12:00:01 | 來源:網(wǎng)站運營
時間:2023-12-03 12:00:01 來源:網(wǎng)站運營
如何用 c 語言搭建一個簡單的網(wǎng)站?:安裝ncapt install nc
寫入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
while truedonc -l -p 8080 -e "./web"done
運行sh web.sh
這是Linux下的方法,Windows下同理。關(guān)鍵詞:簡單,語言
微信公眾號
版權(quán)所有? 億企邦 1997-2025 保留一切法律許可權(quán)利。