-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapp.py
39 lines (31 loc) · 1.21 KB
/
app.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
import os
from datetime import datetime
from flask import Flask, render_template, flash, redirect, url_for, request, g, jsonify, current_app, Markup
from flask_bootstrap import Bootstrap
from flask_wtf.csrf import CSRFProtect
from textapi import process_text
app = Flask(__name__)
basedir = os.path.abspath(os.path.dirname(__file__))
app.config['SECRET_KEY'] = os.environ.get('FOR_DESNOS_ONLY', 'Testkey')
#sqlite_url = 'sqlite:///' + os.path.join(basedir, 'app.db')
#app.config['SQLALCHEMY_DATABASE_URI'] = os.environ.get('DATABASE_URL', sqlite_url)
Bootstrap(app)
CSRFProtect(app)
@app.route('/visualization', methods=['GET', 'POST'])
def text_output():
if request.method == 'POST':
text = request.form.get('user-text') # validated on client
proc = process_text(text)
return render_template('output.html',
words=proc['words'],
word_count=proc['word_count'],
dependencies=Markup(proc['svg']) # must be pre-sanitized
)
else: # GET
return redirect(url_for('index'))
@app.route('/enjamb', methods=['GET'])
def enjamb():
return render_template('input.html')
@app.route('/', methods=['GET'])
def index():
return redirect(url_for('enjamb'))