Skip to content

Commit

Permalink
chore: development server to print out request body to console
Browse files Browse the repository at this point in the history
  • Loading branch information
siddhantgoel committed Nov 6, 2024
1 parent c0265f1 commit 229506d
Show file tree
Hide file tree
Showing 4 changed files with 93 additions and 2 deletions.
3 changes: 3 additions & 0 deletions Justfile
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@ annotate:
compile:
poetry run cython {{parser_pyx}}

server:
poetry run python utils/server.py

# lint

lint: lint-ruff lint-mypy
Expand Down
49 changes: 47 additions & 2 deletions poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ mypy = "^1.13.0"
pytest = "^8.3.3"
requests-toolbelt = "^1.0.0"
ruff = "^0.7.1"
flask = "^3.0.3"

[build-system]
requires = ["poetry-core", "setuptools", "wheel"]
Expand Down
42 changes: 42 additions & 0 deletions utils/server.py
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)

0 comments on commit 229506d

Please sign in to comment.