Я всегда сталкивался с асинхронной операцией, и здесь я снова.
Как мне изменить этот код, чтобы он возвращал do c .id в браузер в переменной шаблона?
import threading
@app.route('/')
def main():
# Create an Event for notifying main thread.
callback_done = threading.Event()
document = ''
# Create a callback on_snapshot function to capture changes
def on_snapshot(col_snapshot, changes, read_time):
print(u'Current names in Database:')
for doc in col_snapshot:
print(u'{}'.format(doc.id))
document = doc.id
callback_done.set()
# Watch the document
query_watch = col_query.on_snapshot(on_snapshot)
# Wait for the callback.
callback_done.wait(timeout=60)
return render_template('index.html', title='Home', document=document)
Спасибо