Skip to content

Instantly share code, notes, and snippets.

@mcdonc
Created August 21, 2018 13:25
Show Gist options
  • Save mcdonc/524f3550f919c57a237be0ccc02610f5 to your computer and use it in GitHub Desktop.
Save mcdonc/524f3550f919c57a237be0ccc02610f5 to your computer and use it in GitHub Desktop.
from wsgiref.simple_server import make_server
from pyramid.config import Configurator
from pyramid import httpexceptions
def nocontent(request):
return httpexceptions.HTTPNoContent()
if __name__ == '__main__':
config = Configurator()
config.add_view(nocontent, route_name='nocontent')
config.add_route('nocontent', '/nocontent')
app = config.make_wsgi_app()
server = make_server('0.0.0.0', 8080, app)
server.serve_forever()
# $ curl -I http://localhost:8080/nocontent
# HTTP/1.0 204 No Content
# Date: Tue, 21 Aug 2018 13:24:06 GMT
# Server: WSGIServer/0.1 Python/2.7.15rc1
# Content-Length: 0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment