from flask import Flask, request, send_from_directory, render_template_string import os app = flask.Flask(__name__, template_folder="./") app.config['DEBUG'] = True @app.route("/") def index(): return flask.render_template('index.html') app = Flask(__name__) UPLOAD_FOLDER = 'static' IMAGE_FILENAME = 'latest_image.jpg' # Создание директории, если она не существует if not os.path.exists(UPLOAD_FOLDER): os.makedirs(UPLOAD_FOLDER) @app.route('/upload', methods=['POST']) def upload_file(): if 'file' not in request.files: return "No file part", 400 file = request.files['file'] if file.filename == '': return "No selected file", 400 file.save(os.path.join(UPLOAD_FOLDER, IMAGE_FILENAME)) return "File uploaded successfully", 200 @app.route('/image') def get_image(): return send_from_directory(UPLOAD_FOLDER, IMAGE_FILENAME) @app.route('/') def index(): html = '''