Created
May 19, 2020 05:46
-
-
Save arajkumar/c7e5da7e35c9011f047a322c0c91bfe2 to your computer and use it in GitHub Desktop.
Pydantic and Flask formdata validation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from flask import Flask | |
from flask import request | |
from werkzeug.datastructures import FileStorage | |
from pydantic import BaseModel | |
app = Flask(__name__) | |
class FormData(BaseModel): | |
file_path: str | |
ecosystem: str | |
manifest: FileStorage | |
class Config: | |
arbitrary_types_allowed = True | |
@app.route('/hello', methods=['POST']) | |
def helloIndex(): | |
print(FormData(**request.form, **request.files)) | |
return 'Hello World from Python Flask!' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment