Backend repository for System23
IP: 34.87.73.138
- For testing project is work temporary: Run docker compose (use Makefile), then hit api with endpoint
/image
(in fileuniversal.py
). ex.127.0.0.1:5000/image/image_name
or34.142.211.35:5000/image/image_name
- Models is created, feel free for add or delete it if you think that's right
- Documentation added in folder docs, feel free to add anything
- Folder
/admin
,/utils
,/docs
- Allow CORS for all domains on all routes
- Column create_at > nullable=False
- Add class history as parent of class model
- Add ERD in
docs
- Add JWT token, this functions add to
utils/auth_token.py
- encode function used when sign-in, this return a token, and it will be expired during 720 minutes or 12 hours
- decode function used in every endpoint which contain
Authorization token
in request header, this return User ID, and it ascurrent_user
in parameter of endpoint
- Every endpoint within decorator
decode_auth_token
must fillAuthorization token
in header. Ex:- Authorization: Jwt xxxx.yyyy.zzzz
- How to hash password? How to store passwords securely using Werkzeug
- How to use errorhandler? Python Flask: error and exception handling
- How to use JWT?
If you forget how to run query use sql or orm, this could be test in file routes/product
. Example:
@products_bp.route("test", methods=["GET"])
def test_only():
run_query(f"DELETE FROM products", True)
run_query(f"INSERT INTO products VALUES ('{uuid.uuid4()}', 'cid1', 'tas', 20, 'lorem', 'S', 'used', 'image1', '[image1, image2]', '{datetime_format()}', 'admin')", True)
run_query(insert(Products).values(id=uuid.uuid4(), category_id="cid2", name="baju", price=100, detail="lorem ipsum", size="L", condition="used", image="image1", images_url=["image4", "image5"], create_at=datetime_format(), create_by="Ardi"), True)
run_query(f"INSERT INTO products (id, category_id, name, price, size, condition, image, create_by) VALUES ('{uuid.uuid4()}', 'cid1', 'tas', 101, 'M', 'new', 'image2', 'Saya')", True)
run_query(insert(Products).values(id=uuid.uuid4(), category_id="cid2", name="baju", price=100, detail="haloooooooo", condition="new", image="image2", create_by='Kamu'), True)
query = run_query("SELECT * FROM products")
orm = run_query(select(Products))
return {
"query": query,
"orm": orm,
},200
- cd .ssh
- ssh-keygen -t rsa -f [
FILENAME
] -C [USERNAME
] -b 2048 - type [
FILENAME
].pub - copy public key to GCP and add in security section
- finally you can connect via ssh using vs code
Test connect in cmd:
- ssh [
USERNAME
]@34.142.211.35 -i [FILENAME
]
Test IP, run command:
- make build
- curl 34.142.211.35:5000/image
home.py
: Homeauth.py
: Authenticationuser.py
:- Profile page
- Cart
- Admin page
universal.py
: Universalorder.py
:- Profile page
- Cart
- Admin page
cart.py
:- Cart
- Product detail page
product.py
:- Product list
- Product detail page
- Admin page
category.py
:- Product list
- Admin page