這裏是燒瓶蟒蛇:http://pastie.org/8712899錯誤500使用jQuery阿賈克斯獲得和瓶
,這裏是在index.html的模板中的HTML + JS:
的問題是,它的工作原理完全被通緝當通過內置的本地服務器運行時,但在使用apache wsgi部署時單擊搜索按鈕時會出現500錯誤。
它是在這裏在線(而不是功能) http://thekindlyone.scribblehead.info/calvinball/
幫助?
這裏是回溯的日誌。
Exception on /search [GET]
Traceback (most recent call last):
File "/usr/local/lib/python2.6/dist-packages/flask/app.py", line 1817, in wsgi_app
response = self.full_dispatch_request()
File "/usr/local/lib/python2.6/dist-packages/flask/app.py", line 1477, in full_dispatch_request
rv = self.handle_user_exception(e)
File "/usr/local/lib/python2.6/dist-packages/flask/app.py", line 1381, in handle_user_exception
reraise(exc_type, exc_value, tb)
File "/usr/local/lib/python2.6/dist-packages/flask/app.py", line 1475, in full_dispatch_request
rv = self.dispatch_request()
File "/usr/local/lib/python2.6/dist-packages/flask/app.py", line 1461, in dispatch_request
return self.view_functions[rule.endpoint](**req.view_args)
File "/home/webdev/thekindlyone/calvinball/calvinball.py", line 42, in find
dbase=database('index')
File "/home/webdev/thekindlyone/calvinball/calvinball.py", line 15, in __init__
self.ix=open_dir(index_dir)
File "/usr/local/lib/python2.6/dist-packages/whoosh/index.py", line 123, in open_dir
return FileIndex(storage, schema=schema, indexname=indexname)
File "/usr/local/lib/python2.6/dist-packages/whoosh/index.py", line 421, in __init__
TOC.read(self.storage, self.indexname, schema=self._schema)
File "/usr/local/lib/python2.6/dist-packages/whoosh/index.py", line 616, in read
gen = cls._latest_generation(storage, indexname)
File "/usr/local/lib/python2.6/dist-packages/whoosh/index.py", line 593, in _latest_generation
for filename in storage:
File "/usr/local/lib/python2.6/dist-packages/whoosh/filedb/filestore.py", line 81, in __iter__
return iter(self.list())
File "/usr/local/lib/python2.6/dist-packages/whoosh/filedb/filestore.py", line 518, in list
files = os.listdir(self.folder)
OSError: [Errno 2] No such file or directory: 'index'
更新:我設置絕對嗖的一聲索引目錄路徑,並以絕對的cnh.cbz路徑。但即使如此,我也得到了error。雖然whoosh索引的作品。是否因爲cnh.cbz文件位於flask應用程序目錄之外?我該如何解決? 這裏是新的Python
from flask import Flask, jsonify, render_template, request
from whoosh.index import open_dir
from whoosh.fields import *
from whoosh.qparser import QueryParser
from whoosh import highlight
import datetime
import zipfile
import logging
app = Flask(__name__)
app.logger.addHandler(logging.FileHandler('/home/webdev/thekindlyone/flasklogs/calvinball.log'))
#yymmdd
class database(object):
def __init__(self,index_dir):
self.ix=open_dir(index_dir)
def search(self,text):
fetched=[]
brf = highlight.UppercaseFormatter()
with self.ix.searcher() as searcher:
query = QueryParser("content", self.ix.schema).parse(text)
results = searcher.search(query)
results.fragmenter=highlight.WholeFragmenter()
results.formatter = brf
for result in results:
fetched.append((result['title'],result.highlights("content")))
return fetched
def makehtml(tuples):
hypertext=''
if tuples:
for title,content in tuples:
ftitle=datetime.datetime.strptime(title[2:], '%y%m%d').strftime('%d/%m/%y')
hypertext+='''<div class="clicker" id="{0}">{1}</div><br>'''.format(title,ftitle+' '+content)
else:
hypertext='Nothing found'
return hypertext
@app.route('/search')
def find():
string = request.args.get('searchstring')
dbase=database('/home/webdev/thekindlyone/calvinball/index')
hypertext=makehtml(dbase.search(string))
return hypertext
@app.route('/')
def index():
return render_template('index.html')
@app.route('/show')
def display():
strip = request.args.get('strip')
z=zipfile.ZipFile('/home/webdev/thekindlyone/cnh.cbz')
img=z.open(strip+'.jpg')
z.close()
data_uri = img.read().encode('base64').replace('\n', '')
img_tag = '<img src="data:image/png;base64,{0}">'.format(data_uri)
return img_tag
if __name__ == '__main__':
app.run(host='0.0.0.0',debug=True)
更新2:我創建了cnh.cbz硬鏈接到燒瓶中的應用程序目錄和它的作品。 但是必須有更好的方法。
將堆棧跟蹤配置爲發送到基於apache的服務器上的日誌文件,這樣,當您遇到500錯誤時,您不會失明。如果您仍然無法理解錯誤,請在您的問題中添加堆棧跟蹤。 – Miguel
@Miguel我不能。當我嘗試登錄時,[This](http://pastie.org/8714023)正在發生。 – thekindlyone