1.搭建Nginx流媒体服务器
2.nginx.conf中添加
c
server {
#listen 80 default_server;
#listen [::]:80 default_server;
location /var/www/html/Dir {
autoindex on;
}
root /var/www/html; # 设置默认网页的根目录
index index.html; # 设置默认网页的文件名
}
- 在/var/www/html中加入
- index.html
c
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>C语言代码示例</title>
<script src="https://cdnjs.cloudflare.com/ajax/libs/prism/1.23.0/prism.min.js"></script>
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/prism/1.24.0/themes/prism.min.css">
</head>
<body>
<h1>示例:C语言代码</h1>
<pre id="codeDisplay">
</pre>
<script src="script.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/prism/1.24.0/prism.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/prism/1.24.0/components/prism-clike.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/prism/1.24.0/components/prism-c.min.js"></script>
<script>
Prism.highlightAll();
</script>
</body>
</html>
- script.js
c
window.addEventListener("DOMContentLoaded", function() {
var codeDisplay = document.getElementById("codeDisplay");
var xhr = new XMLHttpRequest();
xhr.open("GET", "example.c", true);
xhr.onreadystatechange = function() {
if (xhr.readyState === 4 && xhr.status === 200) {
codeDisplay.textContent = xhr.responseText;
Prism.highlightElement(codeDisplay);
}
};
xhr.send();
});
- example.c
c
U16 value = 0;
GetSigVal(H3G_SAM_SIG_GRP01_VOLT_LOW_VLUE, &value); //最低电池电压值-1
data_18132701[0] = (value & 0xFF);
data_18132701[1] = (value & 0xFF00)>>8;
data_18132701[2] = 0;
data_18132701[3] = 0;
GetSigVal(H3G_SAM_SIG_GRP01_VOLT_HIGH_VLUE, &value); //最高电池电压值-1
data_18132701[4] = (value & 0xFF);
data_18132701[5] = (value & 0xFF00)>>8;
data_18132701[6] = 0;
data_18132701[7] = 0;
}
void Set_0x18142701_Data(void)
{
U16 value = 0;
GetSigVal(H3G_SAM_SIG_STRIGN_SOC_LOW_VLUE, &value); //簇最低SOC值-1
data_18142701[0] = (U8)(value/10);
//data_18142701[1] = (value & 0xFF00)>>8;
data_18142701[1] = 0;
data_18142701[2] = 0;
GetSigVal(H3G_SAM_SIG_STRIGN_SOC_HIGH_VLUE, &value); //簇最高SOC值-1
data_18142701[3] = (U8)(value/10);
data_18142701[4] = 0;
data_18142701[5] = 0;
data_18142701[6] = 0;
data_18142701[7] = 0;
}
- 浏览器中输入localhost即可看到