Compare commits

..

No commits in common. "fd341bd9dfbbae8a492deb6a08dfae912681df2f" and "8e52e543f952f7d5aff4deecf5afbd8c981545de" have entirely different histories.

2 changed files with 4 additions and 13 deletions

14
main.py
View File

@ -16,10 +16,6 @@ class Config:
- host
- port
- dbname
App:
- host
- port
- debug
"""
def __init__(self):
"""
@ -32,8 +28,9 @@ class Config:
print('DB not found, creating')
database = mongoclient[self.dbname]
# TODO: Create table if not exists
if 'posts' not in database.list_collection_names():
print('Table not found, creating')
print('Table not fount, creating')
posts = database['posts']
self.posts = posts
@ -114,12 +111,7 @@ class Back():
def deletePost(self, name):
# TODO: return RESTful error/success result
delete = posts.delete_one({'name': name}).deleted_count
if not delete:
result = dict(status=500, count=delete)
else:
result = dict(status=200, count=delete)
return str(result)
return bool(posts.delete_one({'name': name}).deleted_count)
class Metrics:

View File

@ -1,6 +1,5 @@
#!/bin/bash
curl_cmd='curl -w :%{http_code}'
#curl_cmd='curl -s -w "%{http_code}\t%{stdout}" -o /dev/null'
curl_cmd='curl -s -w "%{http_code}" -o /dev/null'
url='server:8080'
$curl_cmd -X POST $url/admin/post/test -F 'body=testpage' && echo ": Create success" || echo ': create fail'