IT记录

日常学习、工作的点滴记录


  • 首页

  • categories

  • archive

  • tags

  • 搜索

flask设置content-disposition正确显示中文

发表于 2023-12-26   |   分类于 Python   |   暂无评论

Flask 中的 Content-Disposition 头部字段可以用于指定浏览器如何处理服务器返回的文件,包括文件下载时的文件名。

如果你需要在 Content-Disposition 中使用中文文件名,可以使用 Unicode 编码,并将编码后的字符串传递给 Response 对象的 headers 参数。

 headers = ("Content-Disposition", f"inline;filename={user_info['fn'].encode('utf-8').decode('latin-1')}")
 as_attachment = False            
 response = make_response(send_file(file_path, as_attachment=as_attachment))
 response.headers[headers[0]] = headers[1]
 return response

将文件名先用 utf-8 编码,然后再用 latin-1 解码,这样 Content-Disposition 中正确显示中文文件名。

Alpine 系统安装应用

发表于 2023-12-21   |   分类于 系统应用   |   暂无评论

Alpine 系统安装应用

更换国内源

sed -i 's/dl-cdn.alpinelinux.org/mirrors.tuna.tsinghua.edu.cn/g' /etc/apk/repositories

安装OpenRC

apk add openrc --no-cache

安装配置ssh

安装

apk add openssh --no-cache

修改root用户密码,修改sshd配置文件/etc/ssh/sshd_config,加入:

PermitRootLogin yes

执行以下命令:

ssh-keygen -A
rc-status
touch /run/openrc/softlevel

重启ssh

service sshd restart

将ssh加入到系统

rc-update add sshd default

此时ssh即可以访问。

安装配置Nginx

安装

apk add nginx
adduser -D -g 'www' www
mkdir /www
chown -R www:www /var/lib/nginx
chown -R www:www /www
mv /etc/nginx/nginx.conf /etc/nginx/nginx.conf.orig

修改配置文件/etc/nginx/nginx.conf

user                            www;
worker_processes                auto; # it will be determinate automatically by the number of core

error_log                       /var/log/nginx/error.log warn;
#pid                             /var/run/nginx/nginx.pid; # it permit you to use rc-service nginx reload|restart|stop|start

events {
    worker_connections          1024;
}

http {
    include                     /etc/nginx/mime.types;
    default_type                application/octet-stream;
    sendfile                    on;
    access_log                  /var/log/nginx/access.log;
    keepalive_timeout           3000;
    server {
        listen                  80;
        root                    /www;
        index                   index.html index.htm;
        server_name             localhost;
        client_max_body_size    32m;
        error_page              500 502 503 504  /50x.html;
        location = /50x.html {
              root              /var/lib/nginx/html;
        }
    }
}

启动系统,并加入随机启动

rc-service nginx start
rc-service nginx reload
rc-service nginx stop
rc-update add nginx default

安装配置Php-fpm

安装,系统默认为8.2版本

apk add php php-fpm
rc-service php-fpm82 start

修改配置文件/etc/nginx/nginx.conf,加入

location ~ \.php$ {
              fastcgi_pass      127.0.0.1:9000;
              fastcgi_index     index.php;
              include           fastcgi.conf;
        }

重启php-fpm

rc-service php-fpm82 restart
rc-update add php-fpm82 default

jupyterlab-git永久保存账号密码

发表于 2023-09-06   |   分类于 Jupyterlab   |   暂无评论

修改配置文件

jupyterlab安装git插件后,会生成一个.git文件夹,修改其中的config文件。添加:

[user]  name = name  //你的用户名

 email = alibaba-inc.com  //邮箱域名

[credential]
    helper = store

使用命令行

git config --global credential.helper store

设定Node.js 参数 max-old-space-size解决内存溢出问题

发表于 2023-08-14   |   分类于 系统应用   |   暂无评论

JavaScript heap out of memory内存溢出问题,一般通过修改max-old-space-size进行解决,解决方法有以下几种:

设定环境变量

export NODE_OPTIONS=--max-old-space-size=8192

使用increase-memory-limit

npm install -g increase-memory-limit
# 从项目的根目录运行
increase-memory-limit

使用命令行

node --max_old_space_size=5000 yourapp.js

第三种方法最为实用有效

新恒源云编译katago13

发表于 2023-06-10   |   分类于 系统应用   |   暂无评论

查看当前Ubuntu系统的版本

lsb_release -a

目前版本被20.04,这样便于下载相应的版本

查看cuda版本

nvcc -V

下载、安装tensorrt

下载tensorrt版本后,进行安装

dpkg -i nv-tensorrt-local-repo-ubuntu2004-8.6.1-cuda-11.8_1.0-1_amd64.deb
cp /var/nv-tensorrt-local-repo-ubuntu2004-8.6.1-cuda-11.8/nv-tensorrt-local-D7BB1B18-keyring.gpg /usr/share/keyrings/
apt update
apt install tensorrt
dpkg-query -W tensorrt

下载编译安装必须的libzip

wget https://libzip.org/download/libzip-1.9.2.tar.gz
tar zxvf libzip-1.9.2.tar.gz
cd libzip-1.9.2
cmake .
make&&make install

编译katago

git clone https://github.com/lightvector/KataGo.git
cd KataGo/cpp
cmake . -DUSE_BACKEND=TENSORRT
make

1234567891011...23

一个高端大气上档次的网站

115 文章
5 分类
51 标签
GitHub 知乎 V2EX SF
© 2026 IT记录
Typecho
主题 - NexT.Pisces