weblab finished

This commit is contained in:
2025-06-08 21:34:30 +08:00
parent ccab1d8e49
commit 603789006c
7 changed files with 527 additions and 2 deletions

43
weblab/Makefile Normal file
View File

@@ -0,0 +1,43 @@
# Makefile for Web Server
CC = gcc
CFLAGS = -Wall -Wextra -std=c99
TARGET = webserver
SOURCE = webserver.c
# 默认目标
all: $(TARGET)
# 编译web服务器
$(TARGET): $(SOURCE)
$(CC) $(CFLAGS) -o $(TARGET) $(SOURCE)
# 创建webroot目录和示例文件
setup:
mkdir -p webroot
@echo "Creating webroot directory and copying index.html..."
# 运行服务器
run: $(TARGET)
./$(TARGET)
# 清理编译文件
clean:
rm -f $(TARGET)
rm -f webserver.log
# 完全清理包括webroot目录
distclean: clean
rm -rf webroot
# 帮助信息
help:
@echo "Available targets:"
@echo " all - Compile the web server"
@echo " setup - Create webroot directory"
@echo " run - Compile and run the server"
@echo " clean - Remove compiled files and logs"
@echo " distclean- Remove everything including webroot"
@echo " help - Show this help message"
.PHONY: all setup run clean distclean help