Merge branch 'testing' of https://gitea.86thumbs.net/waldek/ccpq into testing
This commit is contained in:
commit
85206b4f38
|
@ -1,5 +1,4 @@
|
||||||
bin/
|
bin/
|
||||||
data/
|
|
||||||
include/
|
include/
|
||||||
lib/
|
lib/
|
||||||
__pycache__
|
__pycache__
|
||||||
|
|
|
@ -12,7 +12,10 @@ ANSWER = "ANSWER"
|
||||||
|
|
||||||
|
|
||||||
class Question(object):
|
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):
|
def __init__(self, data):
|
||||||
self._data = data
|
self._data = data
|
||||||
self._clean_data()
|
self._clean_data()
|
||||||
|
|
22
server.py
22
server.py
|
@ -3,3 +3,25 @@
|
||||||
"""
|
"""
|
||||||
Placeholder for the server program
|
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()
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue