14 changed files with 91 additions and 68 deletions
@ -1 +1,24 @@ |
|||||
from functools import total_ordering |
#! /usr/bin/python |
||||
|
|
||||
|
import couchdb |
||||
|
from flask import jsonify |
||||
|
from flask_marshmallow import Marshmallow |
||||
|
|
||||
|
class Posts: |
||||
|
def __init__(self, host=None, port=None): |
||||
|
if host is None: |
||||
|
host = "localhost" |
||||
|
if port is None: |
||||
|
port = "5984" |
||||
|
|
||||
|
self.client = couchdb.Server("http://%s:%s" % (host, port)) |
||||
|
|
||||
|
self.db = self.client["blog"] |
||||
|
|
||||
|
def savepost(self, title, content, author): |
||||
|
doc = { |
||||
|
"title" : title, |
||||
|
"content" : content, |
||||
|
"author" : author |
||||
|
} |
||||
|
return jsonify(self.db.save(doc)) |
||||
|
@ -1,42 +0,0 @@ |
|||||
{% block head %} |
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1"> |
|
||||
<header class="text-center nav navbar"> |
|
||||
<section class="centered page-top navbar-section"> |
|
||||
<h1 class="blog-title">blog</h1> |
|
||||
</section> |
|
||||
</header> |
|
||||
{% endblock %} |
|
||||
|
|
||||
<html> |
|
||||
<body> |
|
||||
{% block content %} |
|
||||
|
|
||||
<posts> |
|
||||
<post></post> |
|
||||
</posts> |
|
||||
<editor> |
|
||||
</editor> |
|
||||
|
|
||||
{% endblock %} |
|
||||
|
|
||||
<footer class="footer"> |
|
||||
</footer> |
|
||||
|
|
||||
{% block styles %} |
|
||||
|
|
||||
<link rel="stylesheet" href="/blog/styles/spectre.min.css"> |
|
||||
<link rel="stylesheet" href="/blog/styles/riotblog.min.css"> |
|
||||
|
|
||||
{% endblock %} |
|
||||
|
|
||||
{% block scripts %} |
|
||||
<script type="text/javascript" src="//cdnjs.cloudflare.com/ajax/libs/fetch/1.0.0/fetch.min.js"></script> |
|
||||
<script type="text/javascript" src="//cdnjs.cloudflare.com/ajax/libs/ramda/0.22.1/ramda.min.js"></script> |
|
||||
<script type="text/javascript" src="//cdnjs.cloudflare.com/ajax/libs/riot/2.6.7/riot+compiler.min.js"></script> |
|
||||
<script type="text/javascript" src="//cdn.jsdelivr.net/riot-route/3.0.2/route.min.js"></script> |
|
||||
<script type="text/javascript" src="/blog/scripts/tags.min.js"></script> |
|
||||
<script type="text/javascript" src="/blog/scripts/riotblog.min.js"></script> |
|
||||
{% endblock %} |
|
||||
|
|
||||
</body> |
|
||||
</html> |
|
@ -1 +1,24 @@ |
|||||
from functools import total_ordering |
#! /usr/bin/python |
||||
|
|
||||
|
import couchdb |
||||
|
from flask import jsonify |
||||
|
from flask_marshmallow import Marshmallow |
||||
|
|
||||
|
class Posts: |
||||
|
def __init__(self, host=None, port=None): |
||||
|
if host is None: |
||||
|
host = "localhost" |
||||
|
if port is None: |
||||
|
port = "5984" |
||||
|
|
||||
|
self.client = couchdb.Server("http://%s:%s" % (host, port)) |
||||
|
|
||||
|
self.db = self.client["blog"] |
||||
|
|
||||
|
def savepost(self, title, content, author): |
||||
|
doc = { |
||||
|
"title" : title, |
||||
|
"content" : content, |
||||
|
"author" : author |
||||
|
} |
||||
|
return jsonify(self.db.save(doc)) |
||||
|
Loading…
Reference in new issue