My freelance client is giving FTP access to the shared hosting, I am new to web development and can't figure out how to deploy the flask app to cgi-bin folder, please help me understand how this works?
.htaccess file
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f # Don't interfere with static files
RewriteRule ^(.*)$ /public_html/app.cgi/$1 [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)
Sorry but the Flask hosting can't be done within Shared-Hosting.
You need DigitalOcean or Heroku or PythonAnywhere (easiest) Hosting to deploy a Flask / Django Website.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.