Repository navigation
Expand file tree
/
Copy pathdenta.py
More file actions
126 lines (98 loc) · 4.82 KB
/
Copy pathdenta.py
File metadata and controls
126 lines (98 loc) · 4.82 KB
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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
from flask import Flask, render_template, request
import pyodbc
import configparser
config = configparser.ConfigParser()
config.read('denta_config.ini')
show_last_count = config['WebServer']['ShowLastEntries']
connection_string = config['WebServer']['DBConnectionString']
app = Flask(__name__)
@app.route('/test')
def show_test():
db_connection = pyodbc.connect(connection_string)
cursor = db_connection.cursor()
cursor.execute("SELECT dateadd(day,datediff(day,1,GETDATE()),0)")
entries = cursor.fetchall()
print(entries)
@app.route('/fullsearch', methods=['GET'])
def show_fullsearch():
name = request.args.get('name')
name1 = name
name2 = name
try:
name1, name2 = name.split(' ')
except Exception:
pass
db_connection = pyodbc.connect(connection_string)
cursor = db_connection.cursor()
cursor.execute("SELECT top 30 "
"imgInfo.chart AS chart, imgInfo.C_Date AS cdate, (injek.name + ' ' + injek.name_F) AS name "
"FROM imgInfo LEFT JOIN injek ON imgInfo.chart = injek.chart "
"WHERE injek.name LIKE '%" + name +"%' OR injek.name_F LIKE '%" + name +"%' "
"OR injek.name LIKE '%" + name1 +"%' OR injek.name_F LIKE '%" + name2 +"%' "
"OR injek.name LIKE '%" + name2 +"%' OR injek.name_F LIKE '%" + name1 +"%' "
"ORDER BY imgInfo.C_Date DESC")
@app.route('/search', methods=['GET'])
def show_search():
name = request.args.get('name')
name1 = name
name2 = name
try:
name1, name2 = name.split(' ')
except Exception:
pass
db_connection = pyodbc.connect(connection_string)
cursor = db_connection.cursor()
cursor.execute("SELECT top 30 "
"imgInfo.chart AS chart, imgInfo.C_Date AS cdate, (injek.name + ' ' + injek.name_F) AS name "
"FROM imgInfo LEFT JOIN injek ON imgInfo.chart = injek.chart "
"WHERE injek.name LIKE '%" + name +"%' OR injek.name_F LIKE '%" + name +"%' "
"OR injek.name LIKE '%" + name1 +"%' OR injek.name_F LIKE '%" + name2 +"%' "
"OR injek.name LIKE '%" + name2 +"%' OR injek.name_F LIKE '%" + name1 +"%' "
"ORDER BY imgInfo.C_Date DESC")
entries = cursor.fetchall()
return render_template('main.html', entries=entries)
@app.route('/month')
def show_month():
db_connection = pyodbc.connect(connection_string)
cursor = db_connection.cursor()
cursor.execute("SELECT "
"imgInfo.chart AS chart, imgInfo.C_Date AS cdate, (injek.name + ' ' + injek.name_F) AS name "
"FROM imgInfo LEFT JOIN injek ON imgInfo.chart = injek.chart "
"WHERE dateadd(day,datediff(day,0,imgInfo.C_Date),0) > dateadd(day,datediff(day,31,GETDATE()),0)"
"ORDER BY imgInfo.C_Date DESC")
entries = cursor.fetchall()
return render_template('main.html', entries=entries)
@app.route('/week')
def show_week():
db_connection = pyodbc.connect(connection_string)
cursor = db_connection.cursor()
cursor.execute("SELECT "
"imgInfo.chart AS chart, imgInfo.C_Date AS cdate, (injek.name + ' ' + injek.name_F) AS name "
"FROM imgInfo LEFT JOIN injek ON imgInfo.chart = injek.chart "
"WHERE dateadd(day,datediff(day,0,imgInfo.C_Date),0) > dateadd(day,datediff(day,7,GETDATE()),0)"
"ORDER BY imgInfo.C_Date DESC")
entries = cursor.fetchall()
return render_template('main.html', entries=entries)
@app.route('/yesterday')
def show_yesterday():
db_connection = pyodbc.connect(connection_string)
cursor = db_connection.cursor()
cursor.execute("SELECT "
"imgInfo.chart AS chart, imgInfo.C_Date AS cdate, (injek.name + ' ' + injek.name_F) AS name "
"FROM imgInfo LEFT JOIN injek ON imgInfo.chart = injek.chart "
"WHERE dateadd(day,datediff(day,0,imgInfo.C_Date),0) = dateadd(day,datediff(day,1,GETDATE()),0)"
"ORDER BY imgInfo.C_Date DESC")
entries = cursor.fetchall()
return render_template('main.html', entries=entries)
@app.route('/')
def show_entries():
db_connection = pyodbc.connect(connection_string)
cursor = db_connection.cursor()
cursor.execute("SELECT top " + show_last_count +
"imgInfo.chart AS chart, imgInfo.C_Date AS cdate, (injek.name + ' ' + injek.name_F) AS name "
"FROM imgInfo LEFT JOIN injek ON imgInfo.chart = injek.chart "
"ORDER BY imgInfo.C_Date DESC")
entries = cursor.fetchall()
return render_template('main.html', entries=entries)
if __name__ == '__main__':
app.run()