统一 UTF-8 编码。 前端使用 HTML(尽量兼容老旧浏览器(NetSurf)且不使用JS)。 服务端使用 python(尽量不引入第三方库),搭建最小轻量化独立聊天室。慢慢来,实现以下功能:
地址:(/)
用户界面:
<fieldset>
<legend>主页</legend>
<label for="nickname">昵称:</label>
<input type="text" id="nickname" name="nickname" value="匿名">
<br>
<label for="roomId">房间号:</label>
<input type="text" id="roomId" name="roomId">
<br>
<button type="submit">进入聊天室</button>
</fieldset>
地址:(/chat?nickname=昵称&roomid=聊天室号码&message=发送消息内容)
用户界面:
<form action="/chat" method="get">
<fieldset>
<legend>主页</legend>
<label for="nickname">昵称</label>
<input type="text" id="nickname" name="nickname" value="匿名">
<br>
<label for="roomid">房间号:</label>
<input type="text" id="roomid" name="roomid" value="默认">
<br>
<button type="submit">进入聊天室</button>
</fieldset>
</form>
<form action="/send_message" method="post">
<fieldset>
<legend>聊天室 - {{ roomid }}</legend>
<textarea id="chatLog" rows="10" cols="50" readonly></textarea>
<br>
<input type="text" id="messageInput">
<button id="sendButton">发送</button>
<button id="exitButton">退出</button>
</fieldset>
</form>
配置读写:
HTTP请求处理:
聊天室管理:
用户交互:
安全与启动:
命令行参数: