diff --git a/.gitignore b/.gitignore index 56055e6..3e9e14b 100644 --- a/.gitignore +++ b/.gitignore @@ -1,5 +1,4 @@ bin/ -data/ include/ lib/ __pycache__ diff --git a/ccpq/lib_ccpq.py b/ccpq/lib_ccpq.py index 9f6c527..c9748ef 100644 --- a/ccpq/lib_ccpq.py +++ b/ccpq/lib_ccpq.py @@ -12,7 +12,10 @@ ANSWER = "ANSWER" class Question(object): - """class to hold the question data and methods""" + """ + class to hold the question data and methods + TODO: needs to json methods for the REST API + """ def __init__(self, data): self._data = data self._clean_data() diff --git a/server.py b/server.py index aaed091..bda26de 100755 --- a/server.py +++ b/server.py @@ -3,3 +3,25 @@ """ Placeholder for the server program """ + +import bottle +import pathlib +from ccpq.lib_ccpq import Question, Game, Database + + +class Server(bottle.Bottle): + """WIP this could be the start of our REST API server""" + def __init__(self, filepath): + bottle.Bottle.__init__(self) + self._db = Database(filepath) + self.route("/question", callback=self._get_question) + + def _get_question(self): + question = self._db.get_question() + return str(question) + +if __name__ == "__main__": + filepath = pathlib.Path("./data/list_book1.csv") + server = Server(filepath) + server.run() +