File: basic_url.py

package info (click to toggle)
python-treq 24.9.1-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 592 kB
  • sloc: python: 4,895; makefile: 130
file content (17 lines) | stat: -rw-r--r-- 425 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
# -*- encoding: utf-8 -*-
from hyperlink import DecodedURL
from twisted.internet.task import react
from _utils import print_response

import treq

def main(reactor):
    url = (
        DecodedURL.from_text(u"https://httpbin.org")
        .child(u"get")      # add path /get
        .add(u"foo", u"&")  # add query ?foo=%26
    )
    print(url.to_text())
    return treq.get(url).addCallback(print_response)

react(main, [])