如何将 Flask 应用程序部署到共享主机上的 cgi-bin 文件夹?
How to deploy flask application to cgi-bin folder on shared hosting?
我的自由客户正在授予 FTP 访问共享主机的权限,我是网络开发的新手,不知道如何将 flask 应用程序部署到 cgi-bin 文件夹,请帮助我了解如何这有用吗?
.htaccess file
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f # Don't interfere with static files
RewriteRule ^(.*)$ /public_html/app.cgi/ [L]
app.py file
import sys, subprocess
# implement pip as a subprocess:
subprocess.check_call([sys.executable, '-m', 'pip', 'install',
'flask'])
from flask import Flask
app = Flask(__name__)
@app.route('/')
def hello():
return "Hello, world"
if __name__ == '__main__':
app.run()
app.cgi file
#!/usr/bin/python3
from wsgiref.handlers import CGIHandler
from app import app
CGIHandler().run(app)
我的自由客户正在授予 FTP 访问共享主机的权限,我是网络开发的新手,不知道如何将 flask 应用程序部署到 cgi-bin 文件夹,请帮助我了解如何这有用吗?
.htaccess file
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f # Don't interfere with static files
RewriteRule ^(.*)$ /public_html/app.cgi/ [L]
app.py file
import sys, subprocess
# implement pip as a subprocess:
subprocess.check_call([sys.executable, '-m', 'pip', 'install',
'flask'])
from flask import Flask
app = Flask(__name__)
@app.route('/')
def hello():
return "Hello, world"
if __name__ == '__main__':
app.run()
app.cgi file
#!/usr/bin/python3
from wsgiref.handlers import CGIHandler
from app import app
CGIHandler().run(app)