DmitrMakeev commited on
Commit
9c74cad
·
verified ·
1 Parent(s): b2938f8

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +12 -8
app.py CHANGED
@@ -120,7 +120,7 @@ def upload_file():
120
  def get_image():
121
  return send_from_directory(UPLOAD_FOLDER, IMAGE_FILENAME)
122
 
123
- @app.route('/')
124
  def index():
125
  html = '''
126
  <!DOCTYPE html>
@@ -207,17 +207,21 @@ def index():
207
  <div id="progress">0%</div>
208
  </div>
209
  </div>
210
- <form id="uploadForm" enctype="multipart/form-data" method="post" action="/upload">
211
- <input type="file" name="photo" id="photoInput">
212
- <button type="submit">Загрузить изображение</button>
213
- </form>
214
  <div id="message"></div>
215
  <h1>Загруженное изображение</h1>
216
  <img id="cameraImage" src="/image" alt="Image" style="width:100%;">
217
  <script>
218
- document.getElementById('uploadForm').addEventListener('submit', function(event) {
219
- event.preventDefault();
220
- var formData = new FormData(this);
 
 
 
 
 
 
221
  fetch('/upload', {
222
  method: 'POST',
223
  body: formData
 
120
  def get_image():
121
  return send_from_directory(UPLOAD_FOLDER, IMAGE_FILENAME)
122
 
123
+ @app.route('/se_mes_im2')
124
  def index():
125
  html = '''
126
  <!DOCTYPE html>
 
207
  <div id="progress">0%</div>
208
  </div>
209
  </div>
210
+ <input type="file" id="photoInput">
211
+ <button id="uploadButton">Загрузить изображение</button>
 
 
212
  <div id="message"></div>
213
  <h1>Загруженное изображение</h1>
214
  <img id="cameraImage" src="/image" alt="Image" style="width:100%;">
215
  <script>
216
+ document.getElementById('uploadButton').addEventListener('click', function() {
217
+ var fileInput = document.getElementById('photoInput');
218
+ var file = fileInput.files[0];
219
+ if (!file) {
220
+ alert('Please select a file.');
221
+ return;
222
+ }
223
+ var formData = new FormData();
224
+ formData.append('photo', file);
225
  fetch('/upload', {
226
  method: 'POST',
227
  body: formData