I search how access to an external web server thanks to couchdb but i don't find.
My web application is stored on couchdb (localhost:5984) and my pictures (format png) are stores on the wev server (localhost:5986) runs with Python.
So, i want to get my pictures via my web application. Here is my configuration for couchdb in the file "local.ini":
[httpd_global_handlers]
_maps = { couch_httpd_proxy, handle_utils_dir_req, "<< localhost:5986 >> " }
[httpd]
enable_cors = true
allow_jsonp = true
[cors]
origins = *
once you access your db, you might want to consider building the url of each documents attachment as follows:
def function():
couch = couchdb.Server() #connect to server
db = couch['img'] #connect to database which contains docs with img attachments
doc_id = [] #create list of id's
http_docid = [] #create list to populate href for picture path
for i in db: #for each id in the db
doc_id.append(i) #add to the carid list
doc = db[i] #get the document id
for key in (doc['_attachments']): #for the key in the doc '_attacments' payload
print key #just to confirm
href_docid.append(('http://yourdbDomain/dbname/'+i+'/'+key)) #create a uri and append to a list
return href_docid
and using Jinja2 templating:
{% for img in function() %}
<img class="some-class" src="{{ img }}">
{% endfor %}`
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.