From 44d71ca2ef416ac466b0d294fd770f0156e51dff Mon Sep 17 00:00:00 2001 From: Max Robinson Date: Thu, 4 Apr 2019 12:48:31 -0600 Subject: [PATCH] Added generate story request on front and back end --- main.py | 10 +++++- templates/index.html | 74 +++++++++++++++++++++++++------------------- 2 files changed, 51 insertions(+), 33 deletions(-) diff --git a/main.py b/main.py index da8b733..abdfc3a 100644 --- a/main.py +++ b/main.py @@ -15,7 +15,7 @@ # [START gae_python37_render_template] import datetime -from flask import Flask, render_template +from flask import Flask, render_template, request app = Flask(__name__) @@ -27,6 +27,14 @@ def root(): return render_template('index.html') +@app.route('/generate', methods=['POST']) +def story_request(): + is_story_block = request.form["story_block"] # is it a full story block or just an action? + prompt = request.form["prompt"] # given prompt + + return "Greetings from the planet Zenon!" + + if __name__ == '__main__': # This is used when running locally only. When deploying to Google App # Engine, a webserver process such as Gunicorn will serve the app. This diff --git a/templates/index.html b/templates/index.html index 1edcdac..a71af33 100644 --- a/templates/index.html +++ b/templates/index.html @@ -1,16 +1,16 @@ - - -Dungeon Dream - - - - - -
+ +// request_story("Hello") + +function request_story(prompt, callback){ + $.post("/generate", { story_block: true, prompt}, + function(data){ + alert(data) + return data; + }); +} + + +
- - + +