简体   繁体   English

使用 CGI 在 Web 服务器上部署 Python

[英]Python deployment on webserver with CGI

I have a python script that I want to make accessible through a website with an userinterface.我有一个 python 脚本,我想通过带有用户界面的网站访问它。

I was experimenting with Flask, but I'm not sure this is the right tool for what I want to do.我正在试验 Flask,但我不确定这是否是我想做的事情的正确工具。

My script takes userdata (.doc/.txt files), does something with it and returns it to the user.我的脚本获取用户数据(.doc/.txt 文件),对其执行一些操作并将其返回给用户。 I don't want to save anything and I don't think that I need a database for this (is this right?).我不想保存任何东西,我认为我不需要为此创建数据库(对吗?)。 The file will be temporarily saved on the server and everything will be deleted once the user downloaded the modified file.该文件将暂时保存在服务器上,一旦用户下载修改后的文件,所有内容将被删除。

My webhosting provider supports Python and only accepts CGI.我的虚拟主机提供商支持 Python,并且只接受 CGI。 I read that WSGI is the preferred method to use with Python and that CGI has scaling issues and can only process one request at a time.我读到 WSGI 是与 Python 一起使用的首选方法,并且 CGI 存在扩展问题并且一次只能处理一个请求。 I'm not sure if I understand this correctly.我不确定我是否理解正确。 If several users would upload files at the same time, the server would only accept one request or overwrite previous requests?如果多个用户同时上传文件,服务器是只接受一个请求还是覆盖之前的请求? Or it can do one request per unique IP address/user?或者它可以为每个唯一的 IP 地址/用户执行一个请求?

Would CGI be ok for the simple get/process/return task of my python script or should I look into a hosting service that uses WSGI? CGI 可以用于我的 python 脚本的简单获取/处理/返回任务,还是我应该研究使用 WSGI 的托管服务?

I had a look at Heroku and Render to deploy a flask app, but I think I could do that through my webhosting provider I guess.我查看了 Heroku 和 Render 来部署一个烧瓶应用程序,但我想我可以通过我的虚拟主机提供商来做到这一点。

For anyone interested in this topic,对于任何对此主题感兴趣的人,

I decided to deploy my app on render.com, which supports gunicorn (WSGI).我决定在支持 gunicorn (WSGI) 的 render.com 上部署我的应用程序。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM