Skip to content

Smol Web App that simulates online shop API

License

Notifications You must be signed in to change notification settings

0dminnimda/enrollment_yandex_academy

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

SBDY_app (School of Backend Development of Yandex)

This is introductory task in the summer School of Backend Development of Yandex 2022.

                       __   __                    __                                                      
                      /\ \ /\ \                  /\ \                                                     
                      \ `\`\/'/   __      ___    \_\ \     __   __  _                                     
                       `\ `\ /' /'__`\  /' _ `\  /'_` \  /'__`\/\ \/'\                                    
                         `\ \ \/\ \L\.\_/\ \/\ \/\ \L\ \/\  __/\/>  </                                    
                           \ \_\ \__/.\_\ \_\ \_\ \___,_\ \____\/\_/\_\                                   
                            \/_/\/__/\/_/\/_/\/_/\/__,_ /\/____/\//\/_/                                   
                       ______                      __                                                     
                      /\  _  \                    /\ \                                                    
                      \ \ \L\ \    ___     __     \_\ \     __    ___ ___   __  __                        
                       \ \  __ \  /'___\ /'__`\   /'_` \  /'__`\/' __` __`\/\ \/\ \                       
                        \ \ \/\ \/\ \__//\ \L\.\_/\ \L\ \/\  __//\ \/\ \/\ \ \ \_\ \                      
                         \ \_\ \_\ \____\ \__/.\_\ \___,_\ \____\ \_\ \_\ \_\/`____ \                     
                          \/_/\/_/\/____/\/__/\/_/\/__,_ /\/____/\/_/\/_/\/_/`/___/> \                    
                                                                                /\___/                    
                                                                                \/__/                     

This is the second task in the process of selection to the School of Backend Development. And this is my take on it.

The description of the task is in the Task.md.

Installation

Open console in the root folder and run

$ pip install .

Launch

After installation just run in the console

$ python -m SBDY_app

or run the python code

from SBDY_app import run
run()

Help

Run

$ python -m SBDY_app -h

to see what arguments run/CLI takes

Application's inner workings

If you visit the folder SBDY_app or specifically SBDY_app/README.md, you can see an overview of how the app works.

REST API documentation

Run the app and then go to http://<host>/docs or http://<host>/redoc
to see and play with an interactive documentation page (both are diffetren)

screenshot

Click on the button "Try it out", it allows you to fill the parameters and directly interact with the API

screenshot

Testing

Visit the folder tests or specifically tests/README.md for documentation

The choice of tools

Web framework

I chose the FastAPI Python Web framework for handling the REST API requests.
Among many other nice things it's performant and asynchronous.

ASGI server

In the role of ASGI server, I chose uvicorn as it seems like the lib used inside of FastAPI.
Also see Choosing the Right ASGI Server for Deploying FastAPI.

Testing framework

Pytest is my favorite testing framework for Python, it's simple and pythonic.
In addition to this, FastAPI recommends using it, so don't mind me if I do ;)

Parsing YAML

To import and use the given openapi.yaml for additional site documentation I used PyYAML.
It seems to be the most popular library for yaml parsing in python, and I don't need anything special, so great choice!

Parsing ISO 8601 datetime

Also I needed to restrictively parse the ISO 8601 formatted strings.
I could not use pydantics datetime validator because it allows too much.
I settled down on ciso8601, it's fast and strict.

Profiling

Also see the folder tests or specifically tests/README.md for documentation on how to run app appropriately for profiling

Open a terminal in the root of the repository and run the commands

$ python -m cProfile -o profile.pstats SBDY_app/__main__.py

to generate a profiling output and run (gprof2dot requeued)

$ python -m gprof2dot -f pstats profile.pstats > profile.gv

to generate a dot file that visualizes the profiling output

gprof2dot

or (snakeviz requeued)

$ python -m snakeviz profile.pstats

to dynamically look through the table of the profiling results

gprof2dot

About

Smol Web App that simulates online shop API

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages