run_api_request.py 474 B

123456789101112131415161718
  1. #!/usr/bin/env python3
  2. # -*- coding: utf-8 -*-
  3. """Run GET and POST requests against the running acme Flask-application."""
  4. from requests import get, post
  5. from time import time
  6. port = 9690
  7. endpoint = 'http://localhost:' + str(port)
  8. print('-- GET: Current message')
  9. print(' > ', get(endpoint).text)
  10. print('-- POST: New message ')
  11. print(' > ', post(endpoint + '?message=message-' + str(int(time()))).text)
  12. print('-- GET: Updated message')
  13. print(' > ', get(endpoint).text)