def user_input(): try: text = request.form['textInput'] image = Scene() image.generate_scene(text) return render_template("scene.html", path='/static/images/scene.png') except Exception as e: print("Exception in views.py (user_input method): ", str(e))
def process_generate_image(body): try: if "type" not in body: return json.dumps({"messgae": "BAD REQUEST"}), 400, {"Content-Type": "application/json"} if body['type'] == "new": if "input" not in body: return json.dumps({"messgae": "BAD REQUEST"}), 400, {"Content-Type": "application/json"} image = Scene() generated_scene = image.generate_scene(body['input']) return json.dumps(generated_scene), 200, {"Content-Type": "application/json"} elif body['type'] == "edit": if "input" not in body and "object" not in body: return json.dumps({"messgae": "BAD REQUEST"}), 400, {"Content-Type": "application/json"} print(body) image = Scene() generated_scene = image.generate_scene(body['input'], body['object']) return json.dumps(generated_scene), 200, {"Content-Type": "application/json"} else: return json.dumps({"messgae": "BAD REQUEST"}), 400, {"Content-Type": "application/json"} except Exception as e: print("Exception in process_generate_image: ", str(e))