Browse Source

working app

main
Michael Pilosov 2 years ago
parent
commit
ea25116d1c
  1. 2
      .gitignore
  2. 2
      Dockerfile
  3. 0
      app/__init__.py
  4. 3
      app/routes.py
  5. 16
      login_user.sh
  6. 16
      signup_user.sh
  7. 13
      test_app.sh

2
.gitignore

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

2
Dockerfile

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

0
app/init.py → app/__init__.py

3
app/routes.py

@ -20,6 +20,9 @@ def process_request():
# Process image, text, and blocks as needed # 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) return jsonify(success=True)
@app.route('/signup', methods=['GET', 'POST']) @app.route('/signup', methods=['GET', 'POST'])

16
login_user.sh

@ -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

@ -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

@ -1,14 +1,21 @@
#!/bin/bash #!/bin/bash
if [ "$#" -ne 1 ]; then if [ "$#" -ne 3 ]; then
echo "Usage: ./test_app.sh <image_path>" echo "Usage: ./test_app.sh <username> <password> <image_path>"
exit 1 exit 1
fi 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 \ curl -X POST \
-H "Content-Type: multipart/form-data" \ -H "Content-Type: multipart/form-data" \
-b cookies.txt \
-F "image=@${IMAGE_PATH}" \ -F "image=@${IMAGE_PATH}" \
-F "text=Sample Text" \ -F "text=Sample Text" \
-F "blocks=Block 1" \ -F "blocks=Block 1" \

Loading…
Cancel
Save