Add simple server

This commit is contained in:
David Todd 2020-01-18 21:39:47 -06:00
parent bf41f258b2
commit 33244503e0
2 changed files with 49 additions and 0 deletions

12
Pipfile Normal file
View File

@ -0,0 +1,12 @@
[[source]]
name = "pypi"
url = "https://pypi.org/simple"
verify_ssl = true
[dev-packages]
[packages]
bottle = "*"
[requires]
python_version = "3.8"

37
server.py Normal file
View File

@ -0,0 +1,37 @@
#!/usr/bin/env python3
# Copyright 2020 - David Todd (c0de@c0defox.es)
# Licensed under the MIT License (https://opensource.org/licenses/MIT)
"""
This file contains the web server for a simple bookmarking application
"""
from bottle import Bottle, run, response, route, template
from api import API
_api = API()
@route('/')
def index():
return template("This is the index")
# I haven't figured out how to get these routes inside the API yet...
@route('/save/<title>/<uri:path>')
def save_bookmark(title, uri):
return _api.save_bookmark(title, uri)
@route('/getall')
@route('/get/all')
def get_all_bookmarks():
return _api.get_all_bookmarks()
@route('/get/<bookmark_id>')
def get_bookmark(bookmark_id):
return _api.get_bookmark(bookmark_id)
@route('/delete/<bookmark_id>')
def delete_bookmark(bookmark_id):
return _api.delete_bookmark(bookmark_id)
if __name__ == '__main__':
run(host='localhost', port=8080)