Skip to content

Commit

Permalink
python function receiving terminal input
Browse files Browse the repository at this point in the history
  • Loading branch information
Srujan Thotapally committed Nov 27, 2016
1 parent f5ea729 commit eaaff28
Show file tree
Hide file tree
Showing 5 changed files with 40 additions and 4 deletions.
2 changes: 1 addition & 1 deletion old_pinacolada-website/run.py
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
from pinacolada_website import app
from web import app
app.run(debug=True)
4 changes: 4 additions & 0 deletions pinacolada_website/__init__.py
Original file line number Diff line number Diff line change
@@ -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)
3 changes: 1 addition & 2 deletions pinacolada_website/templates/index/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,7 @@
<h3 class="masthead-brand">Pi&ntildea Colada</h3>
<nav class="nav nav-masthead">
<a class="nav-link active" href="#">Home</a>
<a class="nav-link" href="#">Features</a>
<a class="nav-link" href="#">Connect to Core</a>
<a class="nav-link" href="{{ url_for('index.terminal') }}">CLI</a>
</nav>
</div>
</div>
Expand Down
30 changes: 30 additions & 0 deletions pinacolada_website/views/index.py
Original file line number Diff line number Diff line change
@@ -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__)

Expand All @@ -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']
5 changes: 4 additions & 1 deletion server.py
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand Down Expand Up @@ -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 = {}

Expand Down

0 comments on commit eaaff28

Please sign in to comment.