首先装一个ncat

yum install ncat
apt get install ncat
whatever...

准备一个html页面文件 data.txt

<html>
        <body>
                <h1>ncat based web server</h1>
                <h1>ncat based web server</h1>
                <h1>ncat based web server</h1>
                <h1>ncat based web server</h1>
                <h1>ncat based web server</h1>
                <h1>ncat based web server</h1>
                <h1>ncat based web server</h1>
        </body>
</html>

开启服务

ncat -lkv 5000 --send-only --sh-exec "echo -e 'cat HTTP/1.1 200 OK\r\n'; cat data.txt"

基于ncat的简易web服务器

相关文章: