Skip to content

Include section about Flask routing #109

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 27 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,33 @@ Send requests to this function using `curl` from another terminal window:
curl localhost:8080
# Output: Hello world!
```
### Quickstart: Flask routing

The framework intializes a Flask `app` behind the scenes. To add Flask routs, you can bring the `app` into scope and
add the desired routes:

```python
from flask import current_app as app

@app.route("/hello/<name>", methods=["GET"])
def hello(name: str):
return f"Hello {name}!", 200


@app.route("/goodbye/<name>", methods=["DELETE"])
def goodbye(name: str):
return f"Goodbye {name}.", 200


def hello(_):
return "Hello world!"
```

You can bring the Flask `Request` object into your global scope by importing it from `flask`.

```python
from flask import request
```

### Quickstart: Error handling

Expand Down