-
-
Notifications
You must be signed in to change notification settings - Fork 33
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore: development server to print out request body to console
- Loading branch information
1 parent
c0265f1
commit 229506d
Showing
4 changed files
with
93 additions
and
2 deletions.
There are no files selected for viewing
This file contains 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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
""" | ||
Development server to print out the raw request body to the console | ||
""" | ||
|
||
from flask import Flask, request, render_template_string | ||
|
||
app = Flask(__name__) | ||
|
||
html = """ | ||
<!doctype html> | ||
<html lang="en"> | ||
<head> | ||
<meta charset="UTF-8"> | ||
<meta name="viewport" content="width=device-width, initial-scale=1.0"> | ||
<title>Upload Files</title> | ||
</head> | ||
<body> | ||
<h1>Upload Files</h1> | ||
<form action="/upload" method="post" enctype="multipart/form-data"> | ||
<label for="file">Choose files:</label> | ||
<input type="file" id="file" name="files" multiple> | ||
<button type="submit">Upload</button> | ||
</form> | ||
</body> | ||
</html> | ||
""" | ||
|
||
|
||
@app.route("/") | ||
def index(): | ||
return render_template_string(html) | ||
|
||
|
||
@app.route("/upload", methods=["POST"]) | ||
def upload(): | ||
print(request.get_data(as_text=True)) | ||
|
||
return "OK", 200 | ||
|
||
|
||
if __name__ == "__main__": | ||
app.run(debug=True) |