看什么看

看什么看
  1. 首页
  2. python
  3. 正文

利用python把服务器目录映射出去

2023年6月26日 545点热度 0人点赞 0条评论

Debian11为例

确保已安装python3
如需安装

apt update
apt install python3

创建service

nano /etc/systemd/system/my-http-server.service

写入配置

[Unit]
Description=My HTTP Server
After=network.target

[Service]
ExecStart=/usr/bin/python3 -m http.server 8080
WorkingDirectory=/path/to/your/directory
Restart=always

[Install]
WantedBy=multi-user.target

重新加载

systemctl daemon-reload

启动服务

systemctl start my-http-server

设置开机自启

systemctl enable my-http-server

 

 

这样就可以通过http://ip:8080来访问这个目录了。

标签: python
最后更新:2023年6月26日

天下无鸡

看什么看

点赞

文章评论

razz evil exclaim smile redface biggrin eek confused idea lol mad twisted rolleyes wink cool arrow neutral cry mrgreen drooling persevering
取消回复

归档

  • 2023 年 9 月
  • 2023 年 8 月
  • 2023 年 7 月
  • 2023 年 6 月

分类

  • docker
  • PVE相关
  • python
  • 服务器相关
  • 杂谈

COPYRIGHT © 2023 看什么看. ALL RIGHTS RESERVED.

Theme Kratos Made By Seaton Jiang