From eaaff2882367919aadd1b6c750e5cec2ddffaf49 Mon Sep 17 00:00:00 2001 From: Srujan Thotapally Date: Sun, 27 Nov 2016 18:35:48 -0500 Subject: [PATCH] python function receiving terminal input --- old_pinacolada-website/run.py | 2 +- pinacolada_website/__init__.py | 4 +++ pinacolada_website/templates/index/index.html | 3 +- pinacolada_website/views/index.py | 30 +++++++++++++++++++ server.py | 5 +++- 5 files changed, 40 insertions(+), 4 deletions(-) diff --git a/old_pinacolada-website/run.py b/old_pinacolada-website/run.py index 3640f4b..13a4ffb 100644 --- a/old_pinacolada-website/run.py +++ b/old_pinacolada-website/run.py @@ -1,2 +1,2 @@ -from pinacolada_website import app +from web import app app.run(debug=True) diff --git a/pinacolada_website/__init__.py b/pinacolada_website/__init__.py index d56c3ab..e688e8e 100644 --- a/pinacolada_website/__init__.py +++ b/pinacolada_website/__init__.py @@ -1,5 +1,9 @@ +from flask_cors import CORS, cross_origin from flask import Flask app = Flask(__name__) +CORS(app) +#app.config["server="] from pinacolada_website.views import index +#i = index.Index() app.register_blueprint(index.mod) \ No newline at end of file diff --git a/pinacolada_website/templates/index/index.html b/pinacolada_website/templates/index/index.html index c04cfdf..e96400a 100644 --- a/pinacolada_website/templates/index/index.html +++ b/pinacolada_website/templates/index/index.html @@ -37,8 +37,7 @@

Piña Colada

diff --git a/pinacolada_website/views/index.py b/pinacolada_website/views/index.py index d9b2535..4e525f2 100644 --- a/pinacolada_website/views/index.py +++ b/pinacolada_website/views/index.py @@ -1,5 +1,27 @@ from flask import Blueprint, render_template, session, redirect, url_for, \ request, flash, g, jsonify, abort +import json + +# class Index(): +# def __init__(self, server): +# self.server = server +# self.mod = Blueprint('index', __name__) + +# @self.mod.route('/') +# def index(): +# return render_template( +# 'index/index.html' +# ) + +# @self.mod.route('/terminal/') +# def terminal(): +# return render_template( +# 'index/terminal.html' +# ) +# @self.mod.route('/command/', methods=['POST']) +# def post(): +# command = request.form['command'] +# print command mod = Blueprint('index', __name__) @@ -9,3 +31,11 @@ def index(): 'index/index.html' ) +@mod.route('/terminal/') +def terminal(): + return render_template( + 'index/terminal.html' + ) +@mod.route('/command/', methods=['POST']) +def post(): + return "YOU TYPED: " + request.form['command'] diff --git a/server.py b/server.py index a1a2f21..31f7852 100644 --- a/server.py +++ b/server.py @@ -68,6 +68,8 @@ def __init__(self, name, port): ################################################################# def server(self): + print "STARTING SERVER\n" + print self.name try: try: self.socket.bind(("0.0.0.0", self.port)) @@ -269,12 +271,13 @@ def print_exc(self, e, msg, always=False): def start_server(): print "Starting web sever..." + #app.config["server"] app.run(debug=True) sys.stdout = os.fdopen(sys.stdout.fileno(), 'w', 0) # force a flushed output for all prints if __name__ == "__main__": web_server = multiprocessing.Process(target=start_server) - #web_server.start() + web_server.start() threads = {} servers = {}