Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
C
CCC-Assignment2-Team69
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Xinjie Lan
CCC-Assignment2-Team69
Commits
c6a86649
Commit
c6a86649
authored
May 6, 2019
by
xinjiel2
Browse files
Options
Downloads
Patches
Plain Diff
edited views
parent
79ce70c9
No related branches found
No related tags found
No related merge requests found
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
web_app_django/tweet/templates/index.html
+3
-3
3 additions, 3 deletions
web_app_django/tweet/templates/index.html
web_app_django/tweet/views.py
+22
-22
22 additions, 22 deletions
web_app_django/tweet/views.py
with
25 additions
and
25 deletions
web_app_django/tweet/templates/index.html
+
3
−
3
View file @
c6a86649
...
...
@@ -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
This diff is collapsed.
Click to expand it.
web_app_django/tweet/views.py
+
22
−
22
View file @
c6a86649
...
...
@@ -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
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment