-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapp.py
68 lines (37 loc) · 1.29 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
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
from lambda_function import lambda_handler
from flask import Flask,render_template,request
import logging
from templates import *
import os
import shutil
from helper import checker
import json
from constants import IMAGE_FOLDER, PDF_NAME,ROOT
from pathlib import Path
app = Flask(__name__)
@app.route('/')
def hello():
return render_template('success.html')
@app.route('/remove')
def remove():
checker('images')
checker('processed_images')
return "thankyou"
@app.route('/home', methods=['GET','POST'])
def home():
if request.method == 'POST' and len(request.files.getlist('img')) > 0:
checker(os.path.join(ROOT,IMAGE_FOLDER))
images = request.files.getlist('img')
for i in range(len(images)):
name = images[i].filename
image_path = os.path.join(ROOT,IMAGE_FOLDER)
images[i].save(os.path.join(image_path,name))
response,name = lambda_handler()
if response == True:
return render_template('pdf_done.html',value = [PDF_NAME])
else:
return f'<h1> {name} </h1>'
return render_template('image_input.html')
if __name__ == '__main__':
app.run()
logging.basicConfig(filename='record.log', level=logging.DEBUG)