-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrun.py
28 lines (26 loc) · 859 Bytes
/
run.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
from flask import Flask, render_template, request
from counts import charcount, specialcount, wordcount, linecount, averagelen
from sorts import commonsort, alphasort
import datetime
app = Flask(__name__)
app.config["DEBUG"] = True
app.config["SEND_FILE_MAX_AGE_DEFAULT"] = 0
@app.route('/', methods=["GET", "POST"])
def index():
if request.method == "POST":
text = request.form["text"]
data = {
"charcount": charcount(text),
"charcount_nospace": charcount(text, spaces=False),
"specialcount": specialcount(text),
"linecount": linecount(text),
"wordcount": wordcount(text),
"averagelen": averagelen(text),
"commonsort": commonsort(text),
"alphasort": alphasort(text),
}
return render_template("index.html", data=data)
if request.method == "GET":
return render_template("index.html",)
if __name__ == "__main__":
app.run()