Skip to content
Snippets Groups Projects
Commit c6a86649 authored by xinjiel2's avatar xinjiel2
Browse files

edited views

parent 79ce70c9
No related branches found
No related tags found
No related merge requests found
......@@ -14,8 +14,8 @@
</form>
<hr>
<ol>
{% for row in rows %}
<li><a id="title" href="/doc/{{ row }}/">{{ row }}</a></li>
{% endfor %}
<li>{{ file.text }}</li>
</ol>
</body> </html>
\ No newline at end of file
......@@ -2,31 +2,31 @@ from django.shortcuts import render
from django.http import Http404,HttpResponseRedirect
from django.shortcuts import render_to_response
from couchdb import Server
try:
SERVER = Server('http://172.18.0.1:5984')
if (len(SERVER) == 0):
SERVER.create('tweet_results')
error = "no"
except:
error = "socket error. Unable to connect to couchdb"
# Create your views here.
def index(request):
try:
if error == "no":
docs = SERVER['tweet_results']
if request.method == "POST":
title = request.POST['title'].replace(' ','')
docs[title] = {'title':title,'text':""}
return HttpResponseRedirect(u"/doc/%s/" % title)
context = {'rows':docs}
print(docs)
print(docs['0f664afca04e2b25008526baf10008ed'])
context = {'file':docs['0f664afca04e2b25008526baf10008ed']}
else:
context = {'file':error}
return render(request,'index.html',context = context)
except:
print(Exception)
def detail(request,id):
docs = SERVER['docs']
doc = docs[id]
if request.method =="POST":
doc['title'] = request.POST['title'].replace(' ','')
doc['text'] = request.POST['text']
docs[id] = doc
return render_to_response('tweet/detail.html',{'row':doc})
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment