Compare commits

...

2 Commits

Author SHA1 Message Date
fd341bd9df Поправил тест
All checks were successful
continuous-integration/drone/push Build is passing
2021-11-01 05:54:36 +03:00
4608125fdf Smol fixes 2021-11-01 05:25:57 +03:00
2 changed files with 13 additions and 4 deletions

14
main.py
View File

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

View File

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