From 2aa1d04931681af6d3395b299ee6bdf57ca2e83b Mon Sep 17 00:00:00 2001 From: rsiddharth Date: Sat, 21 Sep 2019 18:29:40 -0400 Subject: nfsw/io.py: Update query. * nfsw/io.py (query): Flesh out initial structure to process a query. --- nfsw/io.py | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) (limited to 'nfsw/io.py') diff --git a/nfsw/io.py b/nfsw/io.py index 7c65e77..e8d20b6 100644 --- a/nfsw/io.py +++ b/nfsw/io.py @@ -1,4 +1,10 @@ +import functools + +import nfsw.scenes as scenes + from nfsw.auth import login_required, login_required_ajax +from nfsw.redis import redis as r, key as k +from nfsw.scenes import current_scene from flask import ( Blueprint, render_template, request @@ -27,10 +33,21 @@ def io(): @login_required_ajax @preprocess def query(): - cmd = request.get_data(as_text=True) + q = request.get_data(as_text=True) + + # Log query. + r().rpush(k('log'), q) + + # Get current scene. + scene = current_scene() + if scene is None: + return { + 'ans': 'Your game state is fucked. Ping Siddharth.' + } + # Respond. return { - 'ans': cmd + 'ans': scene(q) } -- cgit v1.2.3