Ben flask uygulamasından html şablonuna dizelerin bir listesini geçiyorum, listeyi eklemeye çalışana kadar gayet iyi çalışıyor. Bir istemci tarafı python betiği kullanarak append yöntemini kullanmamı test ettim ve çalışıyor. Listeyi ekleme neden bir iç sunucu hatası neden olduğu şaşkın. İşte burada parametreleriBluemix Python Flask uygulaması liste parametresini list.append() kullanarak kalıba geçirme listesi.()
<ul>
{% for file in files %}
<li>{{ file }}</li>
{% endfor %}
</ul>
kullanan Ve şablonumun bölüm benim şişesi app rota oluyor var
@app.route('/')
def main():
FILES = [ 'test1', 'test2' ]
# Iterate through each file in the cloud storage container
for container in conn.get_account()[1]:
for data in conn.get_container(container['name'])[1]:
print 'object: {0}t size: {1}t date: {2}'.format(data['name'], data['bytes'], data['last_modified'])
FILES.append('test3')
return render_template('index.html', files = FILES)
çizgi FILES.append ('test3') soruna neden olan, ama ben emin değilim neden. Bu satırı yorumladığımda, liste beklediğiniz gibi şablona aktarılır.
İşte ekleme hataya neden, ancak biri açığa değildi gibi
Traceback (most recent call last):
File "/home/vcap/app/.heroku/python/lib/python2.7/site-packages/flask/app.py", line 1836, in __call__
return self.wsgi_app(environ, start_response)
File "/home/vcap/app/.heroku/python/lib/python2.7/site-packages/flask/app.py", line 1820, in wsgi_app
response = self.make_response(self.handle_exception(e))
File "/home/vcap/app/.heroku/python/lib/python2.7/site-packages/flask/app.py", line 1403, in handle_exception
reraise(exc_type, exc_value, tb)
File "/home/vcap/app/.heroku/python/lib/python2.7/site-packages/flask/app.py", line 1817, in wsgi_app
response = self.full_dispatch_request()
File "/home/vcap/app/.heroku/python/lib/python2.7/site-packages/flask/app.py", line 1477, in full_dispatch_request
rv = self.handle_user_exception(e)
File "/home/vcap/app/.heroku/python/lib/python2.7/site-packages/flask/app.py", line 1381, in handle_user_exception
reraise(exc_type, exc_value, tb)
File "/home/vcap/app/.heroku/python/lib/python2.7/site-packages/flask/app.py", line 1475, in full_dispatch_request
rv = self.dispatch_request()
File "/home/vcap/app/.heroku/python/lib/python2.7/site-packages/flask/app.py", line 1461, in dispatch_request
return self.view_functions[rule.endpoint](**req.view_args)
File "/home/vcap/app/server.py", line 93, in main
for container in conn.get_account()[1]:
File "/home/vcap/app/.heroku/python/lib/python2.7/site-packages/swiftclient/client.py", line 1615, in get_account
full_listing=full_listing)
File "/home/vcap/app/.heroku/python/lib/python2.7/site-packages/swiftclient/client.py", line 1553, in _retry
self.url, self.token = self.get_auth()
File "/home/vcap/app/.heroku/python/lib/python2.7/site-packages/swiftclient/client.py", line 1507, in get_auth
timeout=self.timeout)
File "/home/vcap/app/.heroku/python/lib/python2.7/site-packages/swiftclient/client.py", line 617, in get_auth
auth_version=auth_version)
File "/home/vcap/app/.heroku/python/lib/python2.7/site-packages/swiftclient/client.py", line 517, in get_auth_keystone
ksclient, exceptions = _import_keystone_client(auth_version)
File "/home/vcap/app/.heroku/python/lib/python2.7/site-packages/swiftclient/client.py", line 502, in _import_keystone_client
variables to be set or overridden with -A, -U, or -K.''')
ClientException:
Auth versions 2.0 and 3 require python-keystoneclient, install it or use Auth
version 1.0 which requires ST_AUTH, ST_USER, and ST_KEY environment
variables to be set or overridden with -A, -U, or -K.
görünüyor tam traceback bu. Bu bir kez sıralandığında güncellenir.
Gerçek hata nedir? Lütfen tam traceback'i dahil etmek için sorunuzu düzenleyin. Nerede bulacağınızdan emin değilseniz, günlüklerinizi kontrol edin veya hata ayıklama modunu etkinleştirin. – dirn