FileNotFoundError: No such file or directory: '/templates/header.html'

本文介绍了一种文件结构,并讨论了如何在Python脚本中正确地使用绝对路径来引用HTML模板,这对于确保项目的稳定性和跨平台兼容性至关重要。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

文件结构:

- cgi-bin/generage_list.py
- templates/header.html

这里写图片描述

这里写图片描述

解决:
使用绝对路径:

这里写图片描述

#user nobody; worker_processes 1; events { worker_connections 1024; } http { include mime.types; default_type application/octet-stream; sendfile on; #tcp_nopush on; keepalive_timeout 65; #gzip on; # 代理方式 upstream practice { server 182.92.154.131; } # http server server { listen 80; server_name 182.92.154.131; location / { root /usr/share/nginx/html/dist; index index.html index.htm; # 解决history路由模式刷新404 try_files $uri $uri/ /index.html; } # location /backend { # /backend/test/api /test/api # proxy_pass http://backend/; # 加/代表会丢弃/backend # # proxy_pass backend; # 加/代表会丢弃/backend # } # rewrite ^(.*)$ https://$host$1 permanent; error_page 500 502 503 504 /50x.html; location = /50x.html { root html; } } # HTTPS server # server { # listen 80; # server_name 182.92.154.131; # ssl_certificate /usr/share/nginx/https/8603727_182.92.154.131.pem; # ssl_certificate_key /usr/share/nginx/https/8603727_182.92.154.131.key; # ssl_session_cache shared:SSL:1m; # ssl_session_timeout 5m; # ssl_ciphers HIGH:!aNULL:!MD5; # ssl_prefer_server_ciphers on; # location / { # root /usr/share/nginx/html/dist; # index index.html index.htm; # # 解决history路由模式刷新404 # try_files $uri $uri/ /index.html; # } # location /backend { # /backend/test/api /test/api # proxy_pass http://backend:8080/; # 加/代表会丢弃/backend # # proxy_pass backend; # 加/代表会丢弃/backend # } # error_page 500 502 503 504 /50x.html; # location = /50x.html { # root html; # } # } } /usr/share/nginx/html/dist不存在/docker-entrypoint.sh: Looking for shell scripts in /docker-entrypoint.d/ /docker-entrypoint.sh: Launching /docker-entrypoint.d/10-listen-on-ipv6-by-default.sh 10-listen-on-ipv6-by-default.sh: info: Getting the checksum of /etc/nginx/conf.d/default.conf 10-listen-on-ipv6-by-default.sh: info: Enabled listen on IPv6 in /etc/nginx/conf.d/default.conf /docker-entrypoint.sh: Launching /docker-entrypoint.d/20-envsubst-on-templates.sh /docker-entrypoint.sh: Launching /docker-entrypoint.d/30-tune-worker-processes.sh /docker-entrypoint.sh: Configuration complete; ready for start up 2025/03/24 05:22:21 [error] 31#31: *2 rewrite or internal redirection cycle while internally redirecting to “/index.html”, client: 117.189.228.151, server: 182.92.154.131, request: “GET / HTTP/1.1”, host: “182.92.154.131” 117.189.228.151 - - [24/Mar/2025:05:22:21 +0000] “GET / HTTP/1.1” 500 579 “-” “Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/134.0.0.0 Safari/537.36” 2025/03/24 05:22:22 [error] 31#31: *1 rewrite or internal redirection cycle while internally redirecting to “/index.html”, client: 117.189.228.151, server: 182.92.154.131, request: “GET /favicon.ico HTTP/1.1”, host: “182.92.154.131”, referrer: “http://182.92.154.131/” 117.189.228.151 - - [24/Mar/2025:05:22:22 +0000] “GET /favicon.ico HTTP/1.1” 500 579 “http://182.92.154.131/” “Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/134.0.0.0 Safari/537.36” ^C [root@iZ2ze3k6buohug6id3eg97Z nginx]#
03-25
#include "stm32f10x.h" #include "i2c.h" // 假设已经配置好了 I2C 的驱动 #define OLED_ADDRESS 0x78 // SH1106 的 I2C 地址通常是 0x78 (7-bit) void OLED_WriteCommand(uint8_t command) { I2C_Write(OLED_ADDRESS, 0x00, &command, 1); // 0x00 表示写入命令 } void OLED_WriteData(uint8_t *data, uint16_t size) { I2C_Write(OLED_ADDRESS, 0x40, data, size); // 0x40 表示写入数据 } void OLED_Init(void) { // 初始化 OLED 的基本命令 OLED_WriteCommand(0xAE); // 关闭显示 OLED_WriteCommand(0xD5); // 设置时钟分频因子和振荡器频率 OLED_WriteCommand(0x80); OLED_WriteCommand(0xA8); // 设置多路复用率 OLED_WriteCommand(0x3F); // 1/64 duty OLED_WriteCommand(0xD3); // 设置显示偏移 OLED_WriteCommand(0x00); // 不偏移 OLED_WriteCommand(0x40); // 设置显示开始行 OLED_WriteCommand(0x8D); // 充电泵设置 OLED_WriteCommand(0x14); // 开启内部充电泵 OLED_WriteCommand(0x20); // 设置内存地址模式 OLED_WriteCommand(0x00); // 水平地址模式 OLED_WriteCommand(0xA1); // 设置段重映射 OLED_WriteCommand(0xC8); // 设置 COM 输出扫描方向 OLED_WriteCommand(0xDA); // 设置 COM 硬件引脚配置 OLED_WriteCommand(0x12); // COM 引脚配置 OLED_WriteCommand(0x81); // 对比度设置 OLED_WriteCommand(0xCF); // 对比度值 OLED_WriteCommand(0xD9); // 设置预充电周期 OLED_WriteCommand(0xF1); // 预充电周期 OLED_WriteCommand(0xDB); // 设置 VCOMH 电压 OLED_WriteCommand(0x40); // VCOMH 电压值 OLED_WriteCommand(0xA4); // 开启整个显示区域 OLED_WriteCommand(0xA6); // 设置正常显示模式 OLED_WriteCommand(0xAF); // 开启显示 } void OLED_Clear(void) { uint8_t i, j; uint8_t clearData[128]; // SH1106 的有效分辨率为 128x64,每页 128 字节 for (i = 0; i < 8; i++) { // SH1106 分为 8 页 (0-7) OLED_WriteCommand(0xB0 + i); // 设置页地址 OLED_WriteCommand(0x00); // 设置低列地址 OLED_WriteCommand(0x10); // 设置高列地址 for (j = 0; j < 128; j++) { clearData[j] = 0x00; // 清除数据为 0x00 } OLED_WriteData(clearData, 128); // 写入清除数据到显存 } } int main(void) { // 初始化系统时钟、GPIO、I2C 等 OLED_Init(); // 初始化 OLED OLED_Clear(); // 清除 OLED 显示内容 while (1) { // 主循环 } } D:\徐景川作业相关\传感器实验\智能传感与检测技术 实习\sketch_jul10a_copy_20250714175331\sketch_jul10a_copy_20250714175331.ino:1:10: fatal error: stm32f10x.h: No such file or directory compilation terminated. exit status 1 Compilation error: stm32f10x.h: No such file or directory
最新发布
07-19
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值