Update app.py
Browse files
app.py
CHANGED
@@ -1,47 +1,31 @@
|
|
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 |
-
result = reader.readtext(np.array(input_image))
|
34 |
-
|
35 |
-
result_text = [] #empty list for results
|
36 |
-
|
37 |
-
|
38 |
-
for text in result:
|
39 |
-
result_text.append(text[1])
|
40 |
-
|
41 |
-
st.write(result_text)
|
42 |
-
#st.success("Here you go!")
|
43 |
-
st.balloons()
|
44 |
-
else:
|
45 |
-
st.write("Upload an Image")
|
46 |
-
|
47 |
-
st.caption("Made with ❤️ by @1littlecoder. Credits to 🤗 Spaces for Hosting this ")
|
|
|
1 |
+
from analze import *
|
2 |
+
|
3 |
+
app = Flask(__name__)
|
4 |
+
|
5 |
+
@app.route('/')
|
6 |
+
def home():
|
7 |
+
return render_template('home.html')
|
8 |
+
|
9 |
+
@app.route('/upload', methods=['GET', 'POST'])
|
10 |
+
def upload_file():
|
11 |
+
if request.method == 'POST':
|
12 |
+
# Check if a file was uploaded
|
13 |
+
if 'file' not in request.files:
|
14 |
+
return render_template('home.html', content='No file uploaded.')
|
15 |
+
file = request.files['file']
|
16 |
+
# Check if the file has a filename
|
17 |
+
if file.filename == '':
|
18 |
+
return render_template('home.html', content='No file selected.')
|
19 |
+
filepath = 'email files/' + file.filename
|
20 |
+
return render_template('home.html',
|
21 |
+
content=check_file_type(file),
|
22 |
+
features = get_features(filepath),
|
23 |
+
pre_content=predict_content(text_feature(filepath)),
|
24 |
+
pre_tag=predict_html(html_tags_feature(filepath)),
|
25 |
+
pre_num=predict_num(num_feature(filepath)),
|
26 |
+
pre_extra=predict_extra(extra_feature(filepath)))
|
27 |
+
|
28 |
+
return render_template('home.html')
|
29 |
+
|
30 |
+
if __name__ == '__main__':
|
31 |
+
app.run(host='127.0.0.1',port=5000)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|