Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

code review #1

Open
bitkarrot opened this issue Apr 23, 2024 · 0 comments
Open

code review #1

bitkarrot opened this issue Apr 23, 2024 · 0 comments

Comments

@bitkarrot
Copy link

Hi, @PastaGringo

In the test.py you are redefining the variables multiple times, like in a bash script. in python you don't need to do this as its ok to define once at the top and then it will be reused again as the variable state is held, its not like an env var. If on the other hand you want to import the "BASE" from the environment for example, you can do it with this style: https://www.freecodecamp.org/news/python-env-vars-how-to-get-an-environment-variable-in-python/

CallSTR/test.py

Lines 10 to 11 in d20f90a

BASE = "http://0.0.0.0:3000/"
URL = BASE + "convert_key_from/nsec_bech32/nsec1j4c6269y9w0q2er2xjw8sv2ehyrtfxq3jwgdlxj6qfn8z4gjsq5qfvfk99"

When making a class, usually you put multiple methods referencing an object to handle data (aka OOP)
for example of oop https://realpython.com/inheritance-composition-python/

  • The fn_Convert_from_npub_bech32 should be inside the class.
  • name: either all lower case or use camel case. I see a lot of mixing. don't need to start with "fn" to declare its a function.
  • if making an API endpoint it should be shorter without adding in and extra slash section. I'd document the function in the API docs

api.add_resource(Convert_from_nsec_hex, "/convert_key_from/nsec_hex/<string:nsec_hex>")

Suggest endpoint like this: api.add_resource(Convert_from_nsec_hex, "/nsec_hex/<string:nsec_hex>")

class Convert_from_nsec_hex(Resource):

Just a few comments for starters

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant