diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..2c1bd87 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +tiny_BETA.db \ No newline at end of file diff --git a/indexer.py b/indexer.py new file mode 100644 index 0000000..8d5cdbe --- /dev/null +++ b/indexer.py @@ -0,0 +1,56 @@ +#imports +import sqlite3 +import os + +#Init +#DB FORMAT: {fd: (File 'f' or directory 'd'), filename: (Filename duh), path: (path)} +#ex: {"fd":"f","filename":"" +#may add more later +conn = sqlite3.connect('tiny_BETA.db') +files = [] +counter = 0 +#creates cursor +c = conn.cursor() +#create table +c.execute('''CREATE TABLE files + (fd text, filename text, path text)''') + +#Indexes disks: + +for (dirpath, dirnames, filenames) in os.walk('C:'): + #progress "bar" + counter = counter + 1 + if counter == 500: + counter = 0 + print(".", end='') + + for f in filenames: + files.append(("f", f, os.path.join(dirpath, f))) + + for d in dirnames: + files.append(("d", d, os.path.join(dirpath, d))) + +print("C drive indexed!") + +for (dirpath, dirnames, filenames) in os.walk('D:'): + #progress "bar" + counter = counter + 1 + if counter == 500: + counter = 0 + print(".", end='') + + for f in filenames: + files.append(("f", f, os.path.join(dirpath, f))) + + for d in dirnames: + files.append(("d", d, os.path.join(dirpath, d))) + +print("D drive indexed!") + +c.executemany('INSERT INTO files VALUES (?,?,?)', files) +conn.commit() + +print("DB saved! Press enter to see files!") +#print(files) +c.close() + diff --git a/search_engine.py b/search_engine.py new file mode 100644 index 0000000..5ed5bb8 --- /dev/null +++ b/search_engine.py @@ -0,0 +1,33 @@ +from flask import Flask, request, render_template, send_from_directory +import sqlite3, os +app = Flask(__name__) + +conn = sqlite3.connect('tiny_BETA.db') +c = conn.cursor() + +@app.route('/', methods=['GET','POST']) +def hello_world(): + + return render_template("index.html") + +@app.route('/data', methods=['GET', 'POST']) +def index(): + conn = sqlite3.connect('tiny_BETA.db') + c = conn.cursor() + data = request.form['query'] + c.execute("SELECT * FROM files WHERE FILENAME LIKE '%"+data+"%'") + data = c.fetchall() + conn.close() + + return render_template("data.html", len = len(data), data = data) + +@app.route('/img/', methods=['GET', 'POST']) +def send_js(path): + return send_from_directory('templates', path) + + +@app.route('/open/', methods=['GET', 'POST']) +def open(path): + os.system("start "+path) + return "Opened!" + diff --git a/templates/data.html b/templates/data.html new file mode 100644 index 0000000..f5bcbd3 --- /dev/null +++ b/templates/data.html @@ -0,0 +1,15 @@ + + Datalist + + Home + + + + diff --git a/templates/index.html b/templates/index.html new file mode 100644 index 0000000..443613e --- /dev/null +++ b/templates/index.html @@ -0,0 +1,19 @@ + + + + + + +
+ +
+
+ +
+
+ + diff --git a/templates/logo.png b/templates/logo.png new file mode 100644 index 0000000..ed18b02 Binary files /dev/null and b/templates/logo.png differ