两个数字的和:$sum
"; 36 | ?> 37 |
20 | If you see this page, the webserver is successfully setup and 21 | working.
22 | 23 |Use 与佛论禅 at here.
24 | 25 |View an image at here.
26 | 27 |Watch a short video at here.
28 | 29 |View a PHP test page at here.
30 | 31 |Thank you for using this server.
32 | 33 | 34 | -------------------------------------------------------------------------------- /files/get.txt: -------------------------------------------------------------------------------- 1 | GET / HTTP/1.1 2 | Host: localhost 3 | Proxy-Connection: Keep-Alive 4 | X-Request-ID: cd4ff5fbc1bdb64c7cbfca2c787e123f 5 | X-Real-IP: 155.94.194.41 6 | X-Forwarded-For: 155.94.194.41 7 | X-Forwarded-Host: eslzzyl-opulent-bassoon-q6rqqxv7g47399jv-7878.preview.app.github.dev 8 | X-Forwarded-Port: 443 9 | X-Forwarded-Proto: https 10 | X-Original-URI: / 11 | X-Scheme: https 12 | sec-ch-ua: "Microsoft Edge";v="111", "Not(A:Brand";v="8", "Chromium";v="111" 13 | sec-ch-ua-mobile: ?0 14 | sec-ch-ua-platform: "Windows" 15 | upgrade-insecure-requests: 1 16 | user-agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/111.0.0.0 Safari/537.36 Edg/111.0.1661.62 17 | accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.7 18 | sec-fetch-site: same-site 19 | sec-fetch-mode: navigate 20 | sec-fetch-user: ?1 21 | sec-fetch-dest: document 22 | referer: https://eslzzyl-opulent-bassoon-q6rqqxv7g47399jv.github.dev/ 23 | accept-encoding: gzip, deflate, br 24 | accept-language: zh-CN,zh;q=0.9,en;q=0 -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2023 Eslzzyl 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /log4rs.yaml: -------------------------------------------------------------------------------- 1 | # 检查配置文件变动的时间间隔 2 | refresh_rate: 30 seconds 3 | # appender 负责将日志收集到控制台或文件, 可配置多个 4 | appenders: 5 | stdout: 6 | kind: console 7 | encoder: 8 | # log 信息模式,pattern指的是纯文本输出 9 | # https://docs.rs/log4rs/latest/log4rs/encode/pattern/index.html 10 | # d表示时间,下面这种时间设置可以产生类似2016-03-20 14:22:20的时间,时区为本地时区。 11 | # t表示这条日志的target 12 | # m表示日志信息 13 | # n表示平台无关的换行 14 | pattern: "{d(%Y-%m-%d %H:%M:%S)} {h([{l}])} {t} - {m}{n}" 15 | log_file: 16 | kind: rolling_file # 循环写入配置文件 17 | policy: 18 | kind: compound # 默认值, 即使用所有 policy 19 | trigger: # 当文件超过1MB 时触发 rotate 20 | kind: size 21 | limit: 1mb 22 | roller: # rotate 类型 23 | kind: delete # 直接原有文件 24 | path: "files/log/app.log" 25 | append: true # 追加模式, 即每次在已有文件末尾添加日志, 默认为 true 26 | encoder: 27 | pattern: "{d(%Y-%m-%d %H:%M:%S)} {l} {t} - {m}{n}" 28 | # 对全局 log 进行配置 29 | root: 30 | level: info 31 | appenders: 32 | - stdout 33 | - log_file -------------------------------------------------------------------------------- /src/cache.rs: -------------------------------------------------------------------------------- 1 | use std::collections::HashMap; 2 | 3 | use bytes::Bytes; 4 | 5 | /// ### 文件缓存 FileCache 6 | /// 7 | /// 能够容纳一定量的文件的缓存,供Response使用 8 | pub struct FileCache { 9 | cache: HashMap{}
65 | ", code, description 66 | ); 67 | Self { 68 | title, 69 | css, 70 | script: "".to_string(), 71 | body, 72 | } 73 | } 74 | 75 | /// 通过文件列表创建一个`HtmlBuilder` 76 | /// 77 | /// ## 参数 78 | /// - `path`: 路径名 79 | /// - `dir_vec`: 文件列表 80 | /// 81 | /// ## 返回 82 | /// - 一个`HtmlBuilder`对象。要构建它,使用`build()`。 83 | pub fn from_dir(path: &str, dir_vec: &mut Vec| 文件名 | 99 |大小 | 100 |修改时间 | 101 |
| .. | 104 |105 | | 106 | |
| {} | 124 |{} | 125 |{} | 126 |
| {} | 139 |文件夹 | 140 |{} | 141 |
32 | 与佛论禅 33 | 34 |
361 | 与佛论禅帮助 362 |
363 |364 | 听佛讲经(加密):将原文填写在上方输入框,输入箴言(即密码,可选)即可得到佛语(密文); 365 |
366 |367 | 听佛解惑(解密):将佛经(密文)填写在上方,输入箴言(如有)即可得到原文。 368 |
369 |370 | 箴言(可选)是解密所需的密码。 371 |
372 |373 | 376 | 377 |
你指定的网页无法找到。
" 192 | )), 193 | 405 => HtmlBuilder::from_status_code(405, Some( 194 | r"你的浏览器发出了一个非GET方法的HTTP请求。本服务器目前仅支持GET方法。
" 195 | )), 196 | 500 => HtmlBuilder::from_status_code(500, Some( 197 | r"服务器出现了一个内部错误。
" 198 | )), 199 | _ => HtmlBuilder::from_status_code(code, None), 200 | }.build(); 201 | let content_compressed = compress(content.into_bytes(), response.content_encoding).unwrap(); 202 | let bytes = Bytes::from(content_compressed); 203 | response.content_length = bytes.len() as u64; 204 | response.content = Some(bytes); 205 | response.content_type = Some("text/html;charset=utf-8".to_string()); 206 | response.set_code(code); 207 | response 208 | } 209 | 210 | /// 通过目录来生成一个 `Response`,该 `Response` 应当列出目录的所有文件。 211 | /// 212 | /// ## 参数 213 | /// - `path`: 文件的完整路径 214 | /// - `accept_encoding`: 浏览器能够接受的压缩编码,需要根据该参数确定压缩编码 215 | /// - `id`: 用于日志的TCP连接编号 216 | /// - `cache`: 共享的文件缓存指针 217 | /// 218 | /// ## 返回 219 | /// - 一个新的 Response 对象,不完整,还需要进一步处理才能发回浏览器 220 | fn from_dir(path: &str, accept_encoding: Vec