【解決方法】フラスコでPythonプログラムを実行する – 基本的な実行は派手なものではありません

[ad_1]

I have created a program in python, which is an online store which users can add products to their cart and checkout etc.

For the final part I want to finish it with it set up in flask for its own web page.



        <pre lang="Python">
        from flask import Flask
        from delivery import *
        app = Flask(__name__)

        @app.route("/")

        class Main():
             def StartMessage(self):
                 while True:
                     print('''
                              Welcome to The Toy Store

                             Please select which action you would like:
                             1. View store products
                             2. Add item to Shopping Cart
                             3. View Shopping Cart
                             4. Remove item from Shopping Cart
                             5. Calculate Shopping Cart
                             6. Checkout
                             7. Delivery 
                             8. Check product availability
                             9. Exit
                                ''')

                     selection = int(input("Select which action: "))

                     if selection == 1:
                        Products.listProducts(self)

                     elif selection == 2:
                        ShoppingCart.add_products(self)

                     elif selection == 3:
                        ShoppingCart.displayCart(self)

                     elif selection == 4:
                        ShoppingCart.removeitem(self)

                     elif selection == 5:
                        ShoppingCart.totalprice(self)

                     elif selection == 6:
                        Delivery.checkout(self)

                     elif selection == 7:
                        ShoppingCart.postage(self)

                     elif selection == 8:
                        ShoppingCart.check_stock(self)

                     elif selection == 9:
                        print(" Thank you for visiting The Toy Store, we hope to see you again")
                        break

                    else:
                       print("Invalid selection, please try again")
                       break


        startmessage = Main()
        startmessage.StartMessage()

私が試したこと:

Looking online for various tutorials I managed to get the obligatory hello world response on the webpage, I thought if I changes this to add my start message function which welcomes users and lets them pick which action to take it would start on a webpage, however running this the function just works inside the terminal it does not provide the flask root to open up a web page.

解決策 1

[ad_2]

コメント

タイトルとURLをコピーしました