mod_python + flask框架如何调适?
在win下使用xampp,并且安装了mod_python,然后使用flask给的例子,使用以下方法调用函数。
def handler(req):
req.content_type='text/plain'
init_db()
app.run()
return apache.OK
例子为:https://github.com/mitsuhiko/flask/tree/master/examples/flaskr/
apache的http.conf加入了以下代码
<Directory "D:/xampp/htdocs/python/flaskr">
AllowOverride FileInfo
SetHandler python-program
AddHandler mod_python .py
PythonAutoReload On
PythonHandler flaskr
PythonDebug On
然后访问localhost/python/flaskr报错
MOD_PYTHON ERROR
ProcessId: 9880 Interpreter: 'localhost'
ServerName: 'localhost' DocumentRoot: 'D:/xampp/htdocs'
URI: '/python/flaskr/' Location: None Directory: 'D:/xampp/htdocs/python/flaskr/' Filename: 'D:/xampp/htdocs/python/flaskr/' PathInfo: ''
Phase: 'PythonHandler' Handler: 'flaskr'
Traceback (most recent call last):
File "C:\Python27\lib\site-packages\modpython\importer.py", line 1537, in HandlerDispatch default=defaulthandler, arg=req, silent=hlist.silent)
File "C:\Python27\lib\site-packages\modpython\importer.py", line 1202, in _processtarget module = importmodule(modulename, path=path)
File "C:\Python27\lib\site-packages\modpython\importer.py", line 296, in importmodule log, import_path)
File "C:\Python27\lib\site-packages\modpython\importer.py", line 680, in importmodule execfile(file, module.dict)
File "D:\xampp\htdocs\python\flaskr\flaskr.py", line 35, in
File "C:\Python27\lib\site-packages\flask\config.py", line 162, in fromobject obj = importstring(obj)
File "C:\Python27\lib\site-packages\werkzeug-0.8.3-py2.7.egg\werkzeug\utils.py", line 411, in importstring return import(importname)
ImportStringError: importstring() failed for 'mp_d645bbbdbf6c8b566289f00aa0ab7147'. Possible reasons are:
- missing init.py in a package;
- package or module path not included in sys.path;
- duplicated package or module name taking precedence in sys.path;
- missing module, class, function or variable;
Debugged import:
- 'mpd645bbbdbf6c8b566289f00aa0ab7147' not found.
Original exception:
ImportError: No module named mpd645bbbdbf6c8b566289f00aa0ab7147
MODULE CACHE DETAILS
Accessed: Tue May 07 18:04:34 2013 Generation: 0
mpd645bbbdbf6c8b566289f00aa0ab7147 { FileName: 'D:\xampp\htdocs\python\flaskr\flaskr.py' Instance: 1 [IMPORT] Generation: 0 [ERROR] Modified: Tue May 07 16:28:18 2013 }
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论