I'm new to Flask and Python and am currently creating a small web app. The files it has are: Main (Just runs the app), Activate, Checkout, Payment.
I have a bunch of redundant code and variables throughout the 3 other pages such as:
- A function verifying a Shopify webhook
- Generating the "Credentials" portion of a post XML to a different API (Can make into a function)
- Some credentials variables for this API: ID, username, password, pin, referenceNumber, etc.
- Google Sheets API credential variables
Would I be able to just put the functions and variables inside Main.py and just import it to the other 3 files? Would that be good practice? Would it be a problem if some of those other files would access a variable or function from Main at the same time? For example: Checkout and Payment may somehow be accessing the verifyShopifyWebhook() function at the same time since they are run when Shopify sends a webhook to either address.
I also have a bunch of the same imports on Activate, Checkout and Refund. Can I just put the same ones all under Main and import them from Main?
util.pyor something and import it from there