![]() If you access the URL withoutĪ trailing slash ( /projects), Flask redirects you to the canonical URL It’s similar to a folder in a file system. The canonical URL for the projects endpoint has a trailing slash. route ( '/about' ) def about (): return 'The about page' route ( '/projects/' ) def projects (): return 'The project page'. ![]() You need to tell the Flask where your application To run the application, use the flask command or Your application flask.py because this would conflict with Flask Save it as hello.py or something similar. The default content type is HTML, so HTML in the string The function returns the message we want to display in the user’sīrowser. We then use the route() decorator to tell Flask This is needed so that Flask knows where to look for resources such _name_ is aĬonvenient shortcut for this that is appropriate for most cases. ![]() Name of the application’s module or package. Next we create an instance of this class. route ( "/" ) def hello_world (): return "Hello, World!"įirst we imported the Flask class. From flask import Flask app = Flask ( _name_ ).
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |