About this deal
app . get ( '/login' ) def login_get (): return show_the_login_form () @app . post ( '/login' ) def login_post (): return do_the_login () If a DEBUG environment variable is set, drop tables and rebuild. Otherwise, just create the tables once and you're good to go. Views and URL config Move the static and templates folders into hello_app, because these folders certainly contain app code.
The author selected the Free and Open Source Fund to receive a donation as part of the Write for DOnations program. Introduction app = Flask (__name__ ) @app .route ( '/' ) def index ( ) : return render_template ( 'index.html' ) Then set the FLASK_ENV environment variable to development to run the application in development mode and get access to the debugger. For more information about the Flask debugger, see How To Handle Errors in a Flask Application. Use the following commands to do this (on Windows, use set instead of export):
During your work with Flask or any other library, you may want to examine the code in those libraries themselves. VS Code provides two convenient commands that navigate directly to the definitions of classes and other objects in any code: Copy that line into the > prompt at the bottom of the debug console, and try changing the formatting: now.strftime( "%a, %d %B, %Y at %X" ) 'Wed, 31 October, 2018 at 18:13:39' now.strftime( "%a, %d %b, %Y at %X" ) 'Wed, 31 Oct, 2018 at 18:13:39' now.strftime( "%a, %d %b, %y at %X" ) 'Wed, 31 Oct, 18 at 18:13:39'
In the example above, when the app is running and accessed at http://domainname/, a user will receive "Hello, World!" as a response. Connecting the database in Flask Now, whenever you start typing the snippet's prefix, such as flext, VS Code provides the snippet as an autocomplete option, as shown in the next section. You can also use the Insert Snippet command to choose a snippet from a menu. In this new view function, you add a variable rule
The decorator used for the new URL route, /hello/