Issue
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)
Solution
First create a python script which will contain:
import sys
import subprocess
# implement pip as a subprocess:
subprocess.check_call([sys.executable, '-m', 'pip', 'install',
'flask'])
And then follow the instructions given by Hostgator. Please mark it as an answer if it is helpful!
Answered By - Rajdeep
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.