kataniccc commited on
Commit
c59b48d
1 Parent(s): eda494d
Files changed (1) hide show
  1. app.py +33 -5
app.py CHANGED
@@ -1,7 +1,35 @@
1
- import gradio as gr
 
2
 
3
- def greet(name):
4
- return "Hello " + name + "!!"
5
 
6
- iface = gr.Interface(fn=greet, inputs="text", outputs="text")
7
- iface.launch()
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from flask import Flask, request, render_template
2
+ import os
3
 
4
+ app = Flask(__name__)
 
5
 
6
+ UPLOAD_FOLDER = 'uploads'
7
+ ALLOWED_EXTENSIONS = {'png', 'jpg', 'jpeg', 'gif'}
8
+ app.config['UPLOAD_FOLDER'] = UPLOAD_FOLDER
9
+
10
+ def allowed_file(filename):
11
+ return '.' in filename and filename.rsplit('.', 1)[1].lower() in ALLOWED_EXTENSIONS
12
+
13
+ @app.route('/', methods=['GET', 'POST'])
14
+ def upload_file():
15
+ if request.method == 'POST':
16
+ if 'file' not in request.files:
17
+ return render_template('index.html', error='No file part')
18
+
19
+ file = request.files['file']
20
+ if file.filename == '':
21
+ return render_template('index.html', error='No selected file')
22
+
23
+ if file and allowed_file(file.filename):
24
+ filename = file.filename
25
+ filepath = os.path.join(app.config['UPLOAD_FOLDER'], filename)
26
+ file.save(filepath)
27
+
28
+ # Add code to identify bears in the uploaded image
29
+
30
+ return render_template('index.html', filename=filename)
31
+
32
+ return render_template('index.html')
33
+
34
+ if __name__ == '__main__':
35
+ app.run(debug=True)