无法使用Apache和FastCGI启动Flask应用程序

2024-05-06 13:14:28 发布

您现在位置:Python中文网/ 问答频道 /正文

我无法使用Apache web服务器和fcgi部署我的flask hello world应用程序。我对这三个人都是新手,不明白自己做错了什么。以下是我遵循的步骤

这是我申请项目的地点, /Users/John/python/hello_world

应用程序代码hello.py

#!/usr/bin/python2.7

from flask import Flask

app = Flask(__name__)

@app.route('/')
def helloIndex():
    return 'Root !\n'

@app.route('/hello')
def hello():
    return '<h1>Hello World from Python Flask!</h1>'

if __name__ == "__main__":
  app.run(host='localhost', port= 8080)

FastCGI文件hello.fcgi

#!/usr/bin/python2.7
from flup.server.fcgi import WSGIServer
from hello import app

if __name__ == '__main__':
    WSGIServer(app).run()

我已将apache配置文件更改为取消对flask模块的注释

DocumentRoot "/Users/John/python/hello_world"
<Directory "/Users/John/python/hello_world">

LoadModule proxy_fcgi_module libexec/apache2/mod_proxy_fcgi.so

现在,当我启动我的apache服务器时,它会显示It Works !页面,显示本地主机url。但在进行上述配置更改后,它不会显示我的应用程序

请让我知道我的程序有什么问题


Tags: namefromimportapp应用程序flaskhelloworld