-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapp.py
31 lines (25 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
import os
import csv
from flask import Flask, render_template, request
app = Flask(__name__)
def read_tsv_file(file_path):
with open(file_path, 'r', encoding='utf-8') as tsvfile:
reader = csv.DictReader(tsvfile, delimiter='\t')
return [row for row in reader]
current_dir = os.path.dirname(os.path.abspath(__file__))
file_path = os.path.join(current_dir, 'degraders_list.tsv')
degraders_list = read_tsv_file(file_path)
@app.route('/', methods=['GET', 'POST'])
def display_degraders():
if request.method == 'POST':
search_option = request.form['search_option']
search_value = request.form['search_value'].strip()
if search_value:
parts_table = [row for row in degraders_list if row[search_option].lower().startswith(search_value.lower())]
else:
parts_table = []
else:
parts_table = []
return render_template('degraders.html', parts_table=parts_table)
if __name__ == "__main__":
app.run(debug=True)