Let us assume that the file will be sent as a file object using frontend with an identifier key called fileĬsvName = saveToCSV(csvFile=file, extension='.csv') Here is a Youtube Video showing the usecase of the API : ImagePath = os.path.join(imageDirectory, imageName) ImageDirectory = os.path.join(('BASE_URL'), 'static', 'upload', 'image') ImageName = str(uuid.uuid4()) + extension The function saveToImage is implemented as following import uuidĭef saveToImage(imageFile=None, extension='.png'): ImageName = saveToImage(imageFile=image, extension=extension) Router = Blueprint('imageUpload', methods=) Create a separate file called imageUpload.py from flask import Blueprint, request, jsonify Hence the Image will be received as a base64 string that will be decrypted and stored. Let us suppose that the image will be send using the FileReader Javascript API. Now you can simply access that route using Creating routes for Image Upload Now create the server.py file from flask import FlaskĪpp.add_resource('indexRoute', router, url_prefix='/api') Router = Blueprint('routerName', methods=) So let's get started! Basic Blueprint in FlaskĬreate a file called indexRoute.py from flask import Blueprint, jsonify We will create endpoints for creating Image and File Upload. This blog post will cover how to write simple Blueprints using Flask. It is used for making omponents and supporting common patterns within an application or across applications Flask uses what they call as Blueprints to maintain a large and scalable application.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |