说明:之前博主就写过一篇将本地文件上传至VPS服务器的教程→点击查看,虽然该教程使用的jQuery-File-Upload很强大,但配置起来还是有点麻烦,现在再分享一个上传工具,使用Flask+WebUploader实现上传功能,使用起来很简单,但是不如jQuery-File-Upload稳定,不过各有所需,用来上传小文件是足矣的。
截图
安装
Github地址:https://github.com/abbeyokgo/flask_multi_uploader
1、安装依赖
#CentOS 6.x 32位 rpm -ivh http://dl.fedoraproject.org/pub/epel/6/i386/epel-release-6-8.noarch.rpm yum install -y python-pip git #CentOS 6.x 64位 rpm -ivh http://dl.fedoraproject.org/pub/epel/6/x86_64/epel-release-6-8.noarch.rpm yum install -y python-pip git #CentOS 7.x yum install -y epel-release yum install -y python-pip git #如果CentOS 7安装出现No package python-pip available,可以用以下命令进行安装 wget https://bootstrap.pypa.io/get-pip.py python get-pip.py #Debian/Ubuntu系统 apt-get -y update apt-get -y install python-pip git
2、运行程序
git clone https://github.com/abbeyokgo/flask_multi_uploader.git cd flask_multi_uploader #安装依赖 pip install -r requirements.txt #启动程序,8888端口可自行修改 gunicorn -k eventlet -b 0:8888 server:app
如果启动的时候提示-bash: gunicorn: command not found错误,需要先运行命令:
pip install gunicorn
然后再使用命令启动程序,接下来就可以访问IP:8888上传文件了,上传文件保存在upload文件夹。如果Web界面打不开,可能需要开启防火墙端口。
#CentOS 6 iptables -I INPUT -p tcp --dport 8888 -j ACCEPT service iptables save service iptables restart #CentOS 7 firewall-cmd --zone=public --add-port=8888/tcp --permanent firewall-cmd --reload
开启端口后你会发现,启动命令运行出错了,这时候使用Ctrl+C断开命令,再重新使用命令启动即可。
如果你需要常驻后台,就得使用screen命令了,使用查看→传送门。