Created
April 3, 2017 22:16
-
-
Save blythest/4b8afa1c73dd98457f0c8ef68e29bc6c to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from flask import Flask, render_template, redirect, request, g, session, url_for, flash | |
import daemon | |
import config | |
from forms import TextInputForm | |
application = Flask(__name__) | |
application.config.from_object(config) | |
@application.route('/', methods=['GET', 'POST']) | |
def index(): | |
form = TextInputForm() | |
if request.method == 'POST': | |
if form.validate() == False: | |
return render_template('index.html', form=form) | |
else: | |
text_input_str = request.form.to_dict()['textInput'] | |
source_input_str = request.form.to_dict()['source'] | |
if (len(source_input_str) == 0): | |
source_input_str = "Source Unknown" | |
text_unicodestring = text_input_str.encode('utf-8') | |
source_unicodestring = source_input_str.encode('utf-8') | |
all_output = source_unicodestring + '\n' + text_unicodestring | |
with open("testfile.txt","w") as text_output: | |
text_output.write(all_output) | |
daemon.main("python process_text.py") | |
return redirect(url_for('index')) | |
elif request.method == 'GET': | |
return render_template('index.html', form=form) | |
@application.route('/result') | |
def result(): | |
print result | |
return render_template('result.html') | |
if __name__ == "__main__": | |
application.run(debug=True) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment