-
Notifications
You must be signed in to change notification settings - Fork 1
/
app.py
39 lines (31 loc) · 1.01 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
39
import json
from flask import Flask, request, render_template, redirect, url_for, session
import search
app = Flask(__name__)
@app.route("/")
def index():
return render_template("index.html")
@app.route("/templates/result.html")
def result():
return render_template("result.html")
@app.route('/', methods=['POST', 'GET'])
def create():
if request.method == 'POST':
chars = request.form.get('characters')
keys = request.form.get('keywords')
kind = request.form.get('search')
err = int(request.form.get('error'))
if kind == "Filer":
kind = True
else:
kind = False
codes, titles, descriptions = search.search(keys, chars, err, kind)
results = {}
results['codes'] = codes
results['titles'] = titles
results['descriptions'] = descriptions
with open('results.json', 'w') as file:
json.dump(results, file)
return (results, 204)
if __name__ == '__main__':
app.run(debug=True)