-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwebflack.py
45 lines (41 loc) · 1.26 KB
/
webflack.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
40
41
42
43
44
45
from __init__ import *
from flask import Flask, request,render_template
app = Flask(__name__)
global imagedab
global sitep
imagedab = './image/'
sitep = '/site/'
startl()
@app.route('/newimage',methods = ["GET","POST"] )
def NewIm():
if request.method == "POST":
file = request.files["file"]
if TFBD() == True:
with open(imagedab + file.filename,'w') as f:
f = file
NewBlock(file.filename,Hashfiles(imagedab + file.filename))
return '''
<form action="/newimage" method="POST" enctype="multipart/form-data">
<input type="file" name="file">
<button type="submit">Загрузить</button>
</form>'''
@app.route('/index')
def index():
s = ''
if TFBD() == True:
l = os.listdir(path=blockchaindeb)
files = []
for q in l:
files.append(int(q))
files = sorted(files)
del l
if files[-1] > 1:
i = 2
while i <= len(files):
with open(blockchaindeb + '/' + str(i), 'r') as f:
l = json.loads(f.read())
s += 'Name: ' + l["name"] + ' hash: ' + l["ihash"] + '\n'
i += 1
return s
if __name__ == '__main__':
app.run(debug=True)