working app

This commit is contained in:
Michael Pilosov 2023-03-18 17:21:35 -06:00
parent dcf7d50e32
commit ea25116d1c
7 changed files with 48 additions and 4 deletions

2
.gitignore vendored
View File

@ -138,3 +138,5 @@ dmypy.json
# Cython debug symbols
cython_debug/
# Project-specific files
cookies.txt

View File

@ -9,4 +9,4 @@ COPY app app
EXPOSE 5000
CMD ["flask", "run", "--host=0.0.0.0"]
CMD ["flask", "run", "--debug", "--host=0.0.0.0"]

View File

@ -20,6 +20,9 @@ def process_request():
# Process image, text, and blocks as needed
# log to flask log the blocks list.
app.logger.info(blocks)
app.logger.info(text)
return jsonify(success=True)
@app.route('/signup', methods=['GET', 'POST'])

16
login_user.sh Executable file
View File

@ -0,0 +1,16 @@
#!/bin/bash
if [ "$#" -ne 2 ]; then
echo "Usage: ./login_user.sh <username> <password>"
exit 1
fi
USERNAME="$1"
PASSWORD="$2"
curl -X POST \
-H "Content-Type: application/x-www-form-urlencoded" \
-c cookies.txt \
-d "username=${USERNAME}&password=${PASSWORD}" \
http://localhost:5000/login

16
signup_user.sh Executable file
View File

@ -0,0 +1,16 @@
#!/bin/bash
if [ "$#" -ne 2 ]; then
echo "Usage: ./signup_user.sh <username> <password>"
exit 1
fi
USERNAME="$1"
PASSWORD="$2"
curl -X POST \
-H "Content-Type: application/x-www-form-urlencoded" \
-c cookies.txt \
-d "username=${USERNAME}&password=${PASSWORD}" \
http://localhost:5000/signup

13
test_app.sh Normal file → Executable file
View File

@ -1,14 +1,21 @@
#!/bin/bash
if [ "$#" -ne 1 ]; then
echo "Usage: ./test_app.sh <image_path>"
if [ "$#" -ne 3 ]; then
echo "Usage: ./test_app.sh <username> <password> <image_path>"
exit 1
fi
IMAGE_PATH="$1"
USERNAME="$1"
PASSWORD="$2"
IMAGE_PATH="$3"
# Signup and login the user to get the session cookie
./signup_user.sh "${USERNAME}" "${PASSWORD}"
./login_user.sh "${USERNAME}" "${PASSWORD}"
curl -X POST \
-H "Content-Type: multipart/form-data" \
-b cookies.txt \
-F "image=@${IMAGE_PATH}" \
-F "text=Sample Text" \
-F "blocks=Block 1" \