Added all files
This commit is contained in:
parent
7df955704e
commit
879455bc29
|
@ -0,0 +1 @@
|
|||
tiny_BETA.db
|
|
@ -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()
|
||||
|
|
@ -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/<path:path>', methods=['GET', 'POST'])
|
||||
def send_js(path):
|
||||
return send_from_directory('templates', path)
|
||||
|
||||
|
||||
@app.route('/open/<path:path>', methods=['GET', 'POST'])
|
||||
def open(path):
|
||||
os.system("start "+path)
|
||||
return "Opened!"
|
||||
|
|
@ -0,0 +1,15 @@
|
|||
<html>
|
||||
<title>Datalist</title>
|
||||
<body>
|
||||
<a href = "/">Home</a>
|
||||
<img src="/img/logo.png" style="align: center;" height="10%" width="15%">
|
||||
<ul>
|
||||
{%for i in range(0, len)%}
|
||||
<li>
|
||||
<a href="/open/{{data[i][2]}}" style="text-color:green"> {{data[i][1]}} </a>
|
||||
<br>
|
||||
</li>
|
||||
{%endfor%}
|
||||
</ul>
|
||||
</body>
|
||||
</html>
|
|
@ -0,0 +1,19 @@
|
|||
<html>
|
||||
<head>
|
||||
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
|
||||
<style type="text/css">
|
||||
.cbuttons { display: flex; justify-content: center; margin: auto; width: 50%;}
|
||||
#textbox {height:200px;font-size:14pt;}
|
||||
#body {vertical-align: middle;}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<div style="text-align:center; margin-top:auto; margin-bottom:auto;">
|
||||
<img src="/img/logo.png" style="align: center;">
|
||||
<form class="cbuttons" action="/data" method="post">
|
||||
<input type="text" id="textbox" name="query" style="width: 90%; height: 10%;"><br>
|
||||
<input type="submit" value="Search">
|
||||
</form>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
Binary file not shown.
After Width: | Height: | Size: 2.5 KiB |
Loading…
Reference in New Issue