Questions tagged [wsgiref]

40 questions
14
votes
3 answers

Failed to install wsgiref on Python 3

I have a problem installing wsgiref: $ python --version Python 3.6.0 :: Anaconda 4.3.1 (x86_64) $ pip --version pip 9.0.1 from /anaconda/lib/python3.6/site-packages (python 3.6) My requirement.txt file are shown as…
Joey Yi Zhao
  • 37,514
  • 71
  • 268
  • 523
11
votes
2 answers

Control wsgiref simple_server log

I'm playing with wsgiref.simple_server to study the world of web servers. I would like to control the log generated, but could not find anything about it in Python's documentation. My code looks like this: from wsgiref.simple_server import…
gibatronic
  • 1,661
  • 2
  • 17
  • 22
9
votes
1 answer

why use wsgiref simple_server?

I have a simple webapp to build, and I am just beginning to mess around with mod_wsgi. In various tutorials, the first hello world app looks something like the following: def application(environ,start_response): response_body = 'Hello World' …
jmilloy
  • 7,875
  • 11
  • 53
  • 86
9
votes
1 answer

Redirect a user to url with WSGI (no framework)

I am trying to develop a small web application using python's WSGI. For example, if a user chooses Google they would be redirected to google.com, if they chose Facebook they'd be redirected to facebook.com, etc. from wsgiref.simple_server import…
logeekal
  • 525
  • 4
  • 13
7
votes
1 answer

Strange lag/latency/delay/whatever with wsgiref.simple_server after a couple of request

I have an annoying problem. I have this simple server code (let's say): #!/usr/bin/env python3 import wsgiref.simple_server def my_func(env, start_response): start_response('200 OK', []) return [''.encode()] server =…
vpas
  • 513
  • 1
  • 5
  • 18
6
votes
1 answer

Unable to install wsgiref in python 3.x

I can't install wsgiref in python 3. I got these errors. I am using python 3, but I can't install wsgiref I tried pip install wsgiref and pip install wsgiref==0.1.2 E:\CodeWork\Machine…
6
votes
1 answer

Differences between BaseHttpServer and wsgiref.simple_server

I'm looking for a module that provides me a basic http server capabilities for local access. It seems like Python has two methods to implement simple http servers in the standard library: wsgiref.simple_server and BaseHttpServer. What are the…
Guy
  • 1,984
  • 1
  • 16
  • 19
5
votes
3 answers

How do I encode WSGI output in UTF-8?

I want to send an HTML page to the web browser encoded as UTF-8. However the following example fails: from wsgiref.simple_server import make_server def app(environ, start_response): output =…
pthulin
  • 4,001
  • 3
  • 21
  • 23
4
votes
5 answers

using wsgiref.simple_server in unittests

I have some functions like this one: URL = 'http://localhost:8080' def func(): response = urlopen(URL) return process(response) And i want to test it with unittest. I did something like this: from wsgiref.simple_server import…
Mykola Kharechko
  • 3,104
  • 5
  • 31
  • 40
4
votes
2 answers

Error when serving html with WSGI

I am trying to make an application that serves a simple HTML form to the user and then calls a function when the user submits the form. It uses wsgiref.simple_server to serve the HTML. The server is encountering an error and I can't understand why.…
Langston
  • 1,083
  • 10
  • 26
4
votes
1 answer

TCP connection reset occurs when WSGI app responds before consuming environ['wsgi.input']

For our webservice, I wrote some logic to prevent multipart/form-data POSTs larger than, say, 4mb. It boils down to the following (I've stripped away all WebOb usage and just reduced it to plain vanilla WSGI code): import paste.httpserver form =…
Pavel Repin
  • 30,663
  • 1
  • 34
  • 41
3
votes
1 answer

How to catch POST using WSGIREF

I am trying to catch POST data from a simple form. This is the first time I am playing around with WSGIREF and I can't seem to find the correct way to do this. This is the form:
alfredodeza
  • 5,058
  • 4
  • 35
  • 44
3
votes
1 answer

How to get WSGI servers to close a connection after each response?

The API for Python's wsgiref module precludes hop-by-hop headers (as defined in RFC 2616). I'm unclear on how to get the server to terminate a connection after a response (since there doesn't seem to be a way to add Connection: close). This problem…
Raymond Hettinger
  • 216,523
  • 63
  • 388
  • 485
3
votes
1 answer

Serving JPG files via wsgiref.simple_server in Python 3 - "write() argument must be a bytes instance"

I am trying to make a HTTP server in Python3. For the beginning, I only want a server that serves a single JPG file. Here's my code: from wsgiref.simple_server import make_server def simple_app(environ, start_response): headers =…
JustAC0der
  • 2,871
  • 3
  • 32
  • 35
3
votes
5 answers

"AssertionError: write() argument must be a bytes instance" when running WSGISOAPHandler

I have a SOAP server with pysimplesoap in Python 3. Code from wsgiref.simple_server import make_server application = WSGISOAPHandler(dispatcher) wsgid = make_server('', 8008, application) wsgid.serve_forever() I don't know why am I get the…
Jordi Salom
  • 361
  • 2
  • 5
  • 14
1
2 3