我試圖在ubuntu上運行Apache上的燒瓶應用程序。 我得到在瀏覽器這個錯誤:在apache上運行python flask webapp
Internal Server Error
The server encountered an internal error and was unable to complete your request. Either the server is overloaded or there is an error in the application.
的Apache日誌不表示任何錯誤eventhough的日誌級別爲調試。 我WSGI文件看起來像:
import sys
sys.path.insert(0, '/var/www/myflask/')
from run import app as application
我也試過:
from appimport app as application
沒有任何的運氣。 如果我改變WSGI文件內容:
def application(environ, start_response):
status = '200 OK'
output = 'Hello World!'
response_headers = [('Content-type', 'text/plain'),
('Content-Length', str(len(output)))]
start_response(status, response_headers)
return [output]
然後它工作。 另外,如果我在python控制檯中運行我的wsgi的3行,它不會拋出任何異常。 我可以用它自己的獨立的服務器就好了,如下運行應用程序一個run.py SCRPT:
from flask import Flask
app = Flask(__name__)
from app import app
if __name__ == "__main__":
app.run(host='0.0.0.0', port=5000)
這裏是文件系統:
├── app
│ ├── db_access.py
│ ├── db_access.pyc
│ ├── __init__.py
│ ├── __init__.pyc
│ ├── static
│ ├── templates
│ │ └── index.html
│ ├── views.py
│ └── views.pyc
├── __init__.py
├── __init__.pyc
├── myapp.wsgi
├── requirements.txt
├── run.py
├── run.pyc
任何想法如何使它運行阿帕奇? 我已經閱讀: http://flask.pocoo.org/docs/0.10/deploying/mod_wsgi/
http://fosshelp.blogspot.in/2014/03/how-to-deploy-flask-application-with.html
當需要與「python app.py」不同的東西時,我遇到了幾個運行Python腳本的問題。然後我想出了一個Python軟件應該是什麼樣子,並創建了一個名爲Machete的工具(https://pypi.python.org/pypi/machete/)。你可以嘗試一下,創建一個空的(但可運行的)燒瓶應用程序,然後嘗試與你的Apache配置集成......它可能工作。 Python軟件結構有點棘手。 – Lovato 2014-09-05 13:09:42