A HTTP server to use for testing
Project description
Test HTTP Server
================
This is a simple HTTP server that will respond to a single HTTP request and
record some of the data. It is still an early version and doesn't do
everything you probably want.
Installing
==========
pip install testhttpserver
Using in your tests
===================
To create a test server import the server
from testhttpserver import Server
And then create a new instance including the port, response status and
content.
server = Server(8000, response_status=200, response_content='Content')
After you make your request to http://localhost:8000/ . If you POST to the
server it will have ``request_headers``, ``request_content``, and
``request_path`` available.
When you are done remember to ``join()``!
server.join()
See ``tests/test_server.py`` for an example!
Server Parameters
================
port - The port the server will listen on
response_status - int of the status to return
response_content - string of content to return
response_headers - a list of tuples to return as headers
timeout - number of seconds before the server timesout and returns
================
This is a simple HTTP server that will respond to a single HTTP request and
record some of the data. It is still an early version and doesn't do
everything you probably want.
Installing
==========
pip install testhttpserver
Using in your tests
===================
To create a test server import the server
from testhttpserver import Server
And then create a new instance including the port, response status and
content.
server = Server(8000, response_status=200, response_content='Content')
After you make your request to http://localhost:8000/ . If you POST to the
server it will have ``request_headers``, ``request_content``, and
``request_path`` available.
When you are done remember to ``join()``!
server.join()
See ``tests/test_server.py`` for an example!
Server Parameters
================
port - The port the server will listen on
response_status - int of the status to return
response_content - string of content to return
response_headers - a list of tuples to return as headers
timeout - number of seconds before the server timesout and returns
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
testhttpserver-0.1.3.tar.gz
(8.2 kB
view details)
File details
Details for the file testhttpserver-0.1.3.tar.gz
.
File metadata
- Download URL: testhttpserver-0.1.3.tar.gz
- Upload date:
- Size: 8.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | c2875a7acf38fe33bb8e03a1f3b87e18809aaf020e40d985863cae64f2655d41 |
|
MD5 | 77a7fc6d8d85831a982f1d87cda31e13 |
|
BLAKE2b-256 | d214d53c0fac8733234d96c915189a3285ffe49efeeff4dc3daa32b571e47f9d |