小型笔记页面
-
去自己想要存储笔记的目录中,比如很目录下的
mut
目录,去创建notes
目录cd /mnt/
mkdir notes
-
cd notes/
到notes目录下 -
vim auto_add.py
创建auto_add.py
文件# coding=utf-8 import os dir = '/mnt/notes/' htmlbegin = ''' <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta http-equiv="X-UA-Compatible" content="IE=edge"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <title>笔记</title> </head> <!-- <body style="background:#E0EEE8"> --> <body> ''' htmlend = ''' </body> </html> ''' files = os.listdir(dir) lsstr = '' for f in files: if (f!="auto_add.py" and f!="index.html"): htmlbegin += f'''<h5><a href="./{f}" style="text-decoration: none" target="_blank">{f}</a></h4>''' html = htmlbegin + htmlend #print(html) with open(dir+'index.html', 'w') as f: f.writelines(html) f.close()
-
添加
nginx
配置文件前提是 已经成功安装了
nginx
服务apt-get install nginx
-
cd /etc/nginx/conf.d
-
vim notes.conf
编辑notes.conf
文件server { listen 80; server_name note.yanghe.life; location / { root /mnt/notes; #注意路径 index index.html; } }
-
-
然后你的
html
笔记文件就可以放在/mnt/notes/
下了 -
执行
auto_add.py
文件python3 auto_add.py
- 或者把它添加到自动任务中,让系统每隔一段时间去执行
auto_add.py
文件