2021-05-23 16:27:05 +02:00
|
|
|
#!/usr/bin/python3
|
|
|
|
|
|
|
|
"""
|
|
|
|
Placeholder for the server program
|
|
|
|
"""
|
2021-05-23 17:11:23 +02:00
|
|
|
|
|
|
|
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()
|
|
|
|
|