そろそろ煮詰まってきた。
まず、サーバー環境再確認。
1.Pythonのsys.path確認
1) ルート・ディレクトリにて
[ユーザ名 ~]$ python
Python 3.4.1 (default, May 8 2017, 14:41:02)
[GCC 4.4.7 20120313 (Red Hat 4.4.7-3)] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import sys
>>> sys.path
['',
'/usr/local/python/3.4/lib/python34.zip',
'/usr/local/python/3.4/lib/python3.4',
'/usr/local/python/3.4/lib/python3.4/plat-linux','/usr/local/python/3.4/lib/python3.4/lib-dynload',
'/home/users/0/ユーザ名/.local/lib/python3.4/site-packages',
'/usr/local/python/3.4/lib/python3.4/site-packages']
ついでに、flaskのPath
/home/users/0/ユーザ名/.local/bin/flask
2. ) .pyを設置するdirectoryで
[ユーザ名 ~]$ cd web/dest/src
[ユーザ名 src]$ python
Python 3.4.1 (default, May 8 2017, 14:41:02)
[GCC 4.4.7 20120313 (Red Hat 4.4.7-3)] on
linux
Type "help",
"copyright", "credits" or "license" for more
information.>>> import flask
>>>
当然、flask import できますね。
>>> sys.path
['',
'/usr/local/python/3.4/lib/python34.zip','/usr/local/python/3.4/lib/python3.4',
'/usr/local/python/3.4/lib/python3.4/plat-linux',
'/usr/local/python/3.4/lib/python3.4/lib-dynload',
'/home/users/0/ユーザ名/.local/lib/python3.4/site-packages',
'/usr/local/python/3.4/lib/python3.4/site-packages']
sys.pathも、当然、通ってるし。
--------------------------------------------------------------------------------
さて、本番の確認。 3つのファイルの連携が大切。
1. cgiファイル
file名:index.cgi
#!/usr/local/bin/python3.4
import cgitbcgitb.enable()
from wsgiref.handlers import CGIHandler
from test01 import app
CGIHandler().run(app)
2. .htaccess
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$/home/users/0/ユーザ名/web/dest/src/index.cgi/$1 [QSA,L]
3.test01.py
from flask import Flaskapp = Flask(__name__)
@app.route('/')
def index():
return "Hello World!"
if __name__ == '__main__':
app.run()
0 件のコメント:
コメントを投稿