Commit 7ebeab76 authored by omeyer99's avatar omeyer99
Browse files

added some scenarios

parent 229a1ee1
......@@ -6,3 +6,7 @@ ports:
onOpen: open-preview
tasks:
- command: echo "This is an learning environment for flask"
vscode:
extensions:
- "ms-python.python"
\ No newline at end of file
# 01 - Routing
Modern web applications use meaningful URLs to help users. Users are more likely to like a page and come back if the page uses a meaningful URL they can remember and use to directly visit a page.
Use the **route()** decorator to bind a function to a URL.
```
@app.route('/')
def index():
return 'Index Page'
@app.route('/hello')
def hello():
return 'Hello, World'
```
## Variable Rules
You can add variable sections to a URL by marking sections with `<variable_name>`. Your function then receives the `<variable_name>` as a keyword argument. Optionally, you can use a converter to specify the type of the argument like `<converter:variable_name>`.
```
from markupsafe import escape
@app.route('/user/<username>')
def show_user_profile(username):
# show the user profile for that user
return 'User %s' % escape(username)
@app.route('/post/<int:post_id>')
def show_post(post_id):
# show the post with the given id, the id is an integer
return 'Post %d' % post_id
@app.route('/path/<path:subpath>')
def show_subpath(subpath):
# show the subpath after /path/
return 'Subpath %s' % escape(subpath)
```
\ No newline at end of file
https://flask.palletsprojects.com/en/1.1.x/quickstart/
\ No newline at end of file
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment