Saravanan666/pypi-org huggingface dataset:
Package: wsgi-harakiri
WSGI HarakiriAbandonedDon’t use this, it’s not the best way to achieve a request timeout. You’re
probably better off using and improving any such feature built into your wsgi
server, since it will terminate things more reliably.WSGI Middleware that implements a customizable ‘harakiri’ like uWSGI.InstallationUsepip:pipinstallwsgi-harakiriTested on Python 2.7, 3.4, and 3.5.UsageWrap your WSGI application with the middleware, for example for a Django
application in yourwsgi.py:importosfromdjango.core.wsgiimportget_wsgi_applicationos.environ.setdefault("DJANGO_SETTINGS_MODULE","myproject.settings")application=get_wsgi_application()fromwsgi_harakiriimportHarakiriMiddleware# By default adds a request timeout of 30 secondsapplication=HarakiriMiddleware(application)Your appmust notbe running a multi-threaded server (multi-process is ok),
and itmustbe running on a POSIX system. Thealarmsystem call is
used, so thiscannotbe combined with other things that use it, e.g. the
‘harakiri’ functionality in uWSGI.APIHarakiriMiddleware(application, timeout=30, on_harakiri=None, error_app=None)Wraps a WSGI application with the harakiri functionality.applicationmay be any WSGI application.timeoutmay be any integer number of seconds, and defaults to 30.on_harakiriwill be called when a harakiri occurs, from inside the alarm
function - it is thus suitable for logging the stack trace that lead to the
timeout. Its return value is ignored.error_appis a second WSGI application that will be called to produce an
error response when a timeout occurs. The default response is a rather plain
‘500 Internal server error’ with HTML ‘<h1>Page load timeout</h1>’.Example usage with all arguments:application=get_wsgi_application()fromwsgi_harakiriimportHarakiriMiddlewaredefharakiri_handler():logger.error("Harakiri occured",extra={'stack':True})defharakiri_page(environ,start_response):start_response('500 Internal server error',[('Content-Type','text/html')])return[b'<h1>Sorry, this page timed out.</h1>']application=HarakiriMiddleware(application,timeout=15,on_harakiri=harakiri_handler,error_app=harakiri_page,)HarakiriThis is the exception that gets raised when a timeout occurs. You shouldnotcatch it anywhere in your code, however you could use it to detect when
it happens inside a particular code path. For example:fromwsgi_harakiriimportHarakirideffind_users(search_term):conn=make_db_connection()try:returnconn.query(search_term)exceptHarakiri:logger.error("A search timed out",extra={'search_term':search_term})raiseHistoryPending ReleaseNew release notes here1.0.0 (2016-03-28)First release on PyPI, withHarakiriMiddleware.
Package: wsgihatenaauth
wsgi middle ware to authorization with Hatena Auth API.usage::from wsgiref.simple_server import make_server, demo_app
from wsgihatenaauth import HatenaAuthHandlerapiKey = yourHatenaAuthApiKey
secret = yourHatenaAuthSercretKeyapp = HatenaAuthHandler(apiKey=apiKey, secret=secret)(demo_app)
httpd = make_server(‘’, 8000, app)
httpd.serve_forever()
Package: wsgiheaders
Adding and replacing response headers>>> @replaceheader([(r'.*\.html', [('Content-type', 'text/html')])])... def app(environ, start_response):...     start_response('200 OK',...                    [('Content-type', 'text/plain')])...     return ['Hello, world!']>>> import webtest>>> app = webtest.TestApp(app)>>> res = app.get('/a.txt')>>> res.content_type'text/plain'>>> res = app.get('/a.html')>>> res.content_type'text/html'>>> def xrds(environ):...     return [('X-XRDS', environ['wsgi.url_scheme'] + '://' +environ['SERVER_NAME'] + '/svc.xrds')]...>>> def predicate(environ):...     return environ.get('HTTP_ACCEPT', '').find('application/xrds+xml') != -1...>>> @addheader([(predicate, xrds)])... def app(environ, start_response):...     start_response('200 OK',...                    [('Content-type', 'text/plain')])...     return ['Hello, world!']>>> app = webtest.TestApp(app)>>> res = app.get('/')>>> 'X-XRDS' in res.headersFalse>>> res = app.get('/', headers={'Accept':'application/xrds+xml'})>>> res.headers['X-XRDS']'http://localhost/svc.xrds'
Package: wsgi-lineprof
wsgi_lineprofis a WSGI middleware for line-by-line profiling.wsgi_lineprof has the following features:WSGI middleware: It can be integrated with any WSGI-compatible applications and frameworks including Django, Pyramid, Flask, Bottle, and more.Easily pluggable: All configurations for profiling in one place. Users don’t need to make any changes to their application.wsgi_lineprof isnot recommended to be used in production environmentbecause of the overhead of profiling.At a GlanceYou can use wsgi_lineprof as a WSGI middleware of existing applications.$ pip install wsgi_lineprofApply wsgi_lineprof to the existing WSGI web application:fromwsgi_lineprof.middlewareimportLineProfilerMiddlewareapp=LineProfilerMiddleware(app)Start the web application and access the application.
wsgi_lineprof writes results to stdout every time an HTTP request is processed by default.
You can see the output like this in your console:... (snip) ...

File: ./app.py
Name: index
Total time: 1.00518 [sec]
  Line      Hits         Time  Code
===================================
     9                         @app.route('/')
    10                         def index():
    11         1      1005175      time.sleep(1)
    12         1            4      return "Hello world!!"

... (snip) ...Also, you can check the result on your web browser by accessing the special endpoint/wsgi_lineprof/.Please checkthe documentationfor more details.
Package: wsgi_lite
Wouldn’t it be nice if writingcorrectWSGI middleware was this simple?>>> from wsgi_lite import lite, lighten

>>> def latinator(app):
...
...     # Make sure that `app` can be invoked via the Lite protocol, even
...     # if it's a standard WSGI 1 app:
...     app = lighten(app)
...
...     @lite
...     def middleware(environ):
...         status, headers, body = app(environ)
...         for name, value in headers:
...             if name.lower()=='content-type' and value=='text/plain':
...                 break
...         else:
...             # Not text/plain, pass the request through unchanged
...             return status, headers, body
...
...         # Strip content-length if present, else it'll be wrong
...         headers = [
...             (name, value) for name, value in headers
...                 if name.lower() != 'content-length'
...         ]
...         return status, headers, (piglatin(data) for data in body)
...
...     return middlewareUsing just two decorators, WSGI Lite lets you create correct and compliant
middleware and applications, without needing to worry aboutstart_response,writeandclosecalls.  And with thosesametwo decorators, it also
lets you manage resources to be released at the end of a request, and
automatically pass in keyword arguments to your apps or middleware that
are obtained from the WSGI environment (like WSGI server extensions or
middleware-supplied parameters such as request or session objects).For more details, check out theproject’s home page on BitBucket, and scroll down to the
table of contents.WSGI Lite is currently only available for Python 2.x (tested w/2.3 up to 2.7)
but the source should be quite portable to 3.x, as its magic is limited to
inspecting function argument names, and cloning functions usingnew.function().
Package: wsgi_lithium
WSGI LithiumA lightweight and dumb HTTP to WSGI server that relies on Python's included
batteries.This WSGI server is intended to be used in Kubernetes-like environments, where
some component handle load-balancing, application crashing, loggin, etc.How to installpip install wsgi_lithiumHow to useWSGI Lithiumshouldbe used behind a reverse proxy.wsgi-lithium -b [::]:8000 module:appHow to setSCRIPT_NAMEfrom the HTTP serverSimply configure your reverse proxy to set theVirtual-Locationheader to the
value you want inSCRIPT_NAME. Youmighthave to rewrite the path with
said reverse proxy.For example, if you serve an application on/foo/bar, where/baris the sub
path, and/foois the "virtual location", set theVirtual-Locationheader to/fooand rewrite the path so it become/bar.
Package: wsgi-liveserver
wsgi-liveserver provides a simple LiverServerTestCase class that can be used to
help start a web server in the background to serve a WSGI compliant application
for use with testing. Generally it will be used in conjuction with something
like Selenium to perform a series of functional tests using a browser.Licensed under the GNU GPL v3Copyright (c) 2013 John Kristensen (unless explicitly stated otherwise).Installation and DependenciesInstall wsgi-liveserver withpip installwsgi-liveserveror justdownload
wsgi_liveserver.pyand place it
in your project directory. There are no dependencies other than the Python
Standard Library.UsageThe wsgi-liveserverLiveServerTestCasecan be used instead ofunittest.TestCasefor any tests that require a running web server. Simply
define acreate_app()method that returns the WSGI application that you want
to have started up in the background, then write your tests as normal.LiveServerTestCasewill handle starting and stopping the server for you.Port RangeBy defaultLiveServerTestCasewill attempt to listen on the first available
port in the range 8080-8090 (inclusive). If you wish the LiveServer to attempt
to listen on a different range of ports this can be done by setting theport_rangeclass attribute (see the example below).ExampleThe following is a very basic example of using wsgi-liveserver with thewsgiref demo_app:importunittestfromwsgiref.simple_serverimportdemo_appfromseleniumimportwebdriverfromwsgi_liveserverimportLiveServerTestCaseclassSimpleTest(LiveServerTestCase):port_range=(9001,9010)# default is (8080, 8090)defcreate_app(self):returndemo_appdefsetUp(self):self.driver=webdriver.Firefox()deftearDown(self):self.driver.close()deftest_page_title(self):self.driver.get(self.url_base())self.assertTrue('Hello world!'inself.driver.page_source)if__name__=='__main__':unittest.main()Another simple but fully functionalbottleweb
application with tests can be found at:https://github.com/jerrykan/bottle-seleniumContactSend your questions, comments, patches to John Kristensen <john@jerrykan.com>
Package: wsgilog
Supports logging events in WSGI applications to
STDOUT, time rotated log files, email, syslog, and web servers. Also
supports catching and sending HTML-formatted exception tracebacks to a
web browser for debugging.Simple usage example:from wsgilog import log

@log(tohtml=True, tofile='wsgi.log', tostream=True, toprint=True)
def app(environ, start_response):
    print 'STDOUT is logged.'
    environ['wsgilog.logger'].info('This information is logged.')
    # Exception will be logged and sent to the browser formatted as HTML.
    raise Exception()

if __name__ == '__main__':
     from wsgiref.simple_server import make_server
     http = make_server('', 8080, app)
     http.serve_forever()
Package: wsgimagic
Welcome to WSGIMagic!The use of API Gateways backed by Serverless functions is currently expanding at a massive rate, however every provider
has their own special way of presenting the HTTP request to the backend. This means a lot of very boring, very tedious
work for us developers every time we want to use a new service. The goal of this package is to remove the barrier between
the different cloud providers, and allow you to focus on wrting good old Python WSGI APIs.The first environment that has been targeted is the combination of the AWS API Gateway ending as a proxy to AWS Lambda.
Before you would need to find out how Amazon was structuring the incoming request information, and how to send that
informaton back to get a proper response to the client. WSGIMagic allows you to handle everything with a basic decorator.
The following example illustrates a very small example using Flask.from flask import Flaskfrom wsgimagic.aws_lambda import lambda_magicapp = Flask(name)@app.route('/hello', allowed_methods=['GET'])
def hello()
return 'Hello World'@lambda_magic(app)
def event_handler(event, context):
passBy using the lambda_magic decorator, the incoming API Gateway event will automatically be translated to the WSGI format
and passed off to your application. For basic request handling, this is all you need to do. The lambda_magic decorator
also allows you to specify additional response headers that need to be added, define the server name and port that your
app will be told it is running under, and provide a custom error handler in case something goes really wrong with your
requests. I will add more written documentation in the near future, however all of the functions should have decent doc
strings that will provide any other available features.Long term this package will aim to provide similar decorators for other Serverless providers who also do not pass HTTP
messages along pre-translated to the WSGI format.
Package: wsgim-record
WSGI middleware for conditionally recording request/response information.Install it:$pipinstallwsgim-record...and use it:importwsgim_recordclassRecordMiddleware(wsgim_record.RecordMiddleware)# tell what to recorddefrecord_input(self,environ)returnTruedefrecord_errors(self,environ)returnFalsedefrecord_output(self,environ,status,headers,exc_info=None)returnTrue# what was recordeddefrecorded(self,environ,input,errors,status,headers,output):...wrapped=RecordMiddleware(app)
Package: wsgim-rip
WSGI middleware for setting:environ["REMOTE_ADDR"]based on:environ["HTTP_X_FORWARDED_FOR"]and proxy information.Install it:$pipinstallwsgim-rip...and use it:fromwsgim_ripimportRIPMiddlewarewrapped=RIPMiddleware(app,internal='10.0.0.0/8',proxies={'50.18.213.180':'192.168.0.0/16',},))
Package: wsgioauth.zodb
OverviewThe wsgioauth.zodb package is a library that extends the wsgioauth parent package by adding support for the Zope Object Database (ZODB).ExampleThe example requires you to setup a ZEO instance.  You can setup a ZEO instance using the following two commands (setup may very depending on your system setup):$ $PATH_TO/mkzeoinst myzeo
$ myzeo/bin/zeoctl startAt this point the ZEO instance should be running on the default port 8100.  Next, you run the example using PasteDeploy and the wsgioauth package’s consumer example with the following commands:$ cd $PATH_TO/wsgioauth.zodb
$ paster serve run.ini &
$ cd $PATH_TO/wsgioauth
$ python example/consumer.py &Open your web browser and go to the addresshttp://localhost:8081/(location where the consumer is running).  There you will be given a link to print your vacation picture (see the OAuth specification for details about this example use-case).  After clicking this link the consumer obtains the access token to make a call to the protected resource for the image.  In this case we are simply using an echo application to echo the parameters.  The results will show on thehttp://localhost:8081/print_vacationpage, along with a link back to the index page.  The access token information will be displayed on the index page after it has been acquired.Changelog0.2 (2010-01-25)Initial public release.Wrote an example that can be run using the paster configuration file and the parent package’s consumer example.0.1 (2010-01-00)Created the classes that one would use to store OAuth info in the ZODB.LicenseCopyright (c) 2008-2009 The Pennsylvania State University. WebLion packages are developed and maintained by the WebLion Group and its partners.This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.This document is written using the Structured Text format for conversion into alternative formats.
Package: wsgi-objgraph
wsgi-objgraphis wsgi middleware forobjgraph.wsgi middlewarewsgi-objgraphprovides middleware:app = wsgiobjgraph(app)You can see counts of most common types at.objgraph/most_common_types.paste filterwsgi-objgraphhas entry point topaste.filter_factory.[pipeline:main]
pipeline =
  egg:wsgi-objgraph
  yourapp
Package: wsgi_party
wsgi_party’s goals for Python web developers:Refactor legacy projects one route at a time; graft instead of rewrite.Try new ideas from meetups/conferences in isolation; increase velocity.Integrate multiple web frameworks; use the right tool for the job.wsgi_party is for WSGI framework developers. See individual frameworks and
extensions for support. The initial intent was to build URLs across independent
applications, but other exchanges are possible if they are supported by all
frameworks in use.The wsgi_party module provides the WSGIParty middleware which allows all
mounted applications to hook in handlers for cross-application communication
within a single WSGI process. Mount individual applications in a dispatcher,
then wrap the dispatcher with WSGIParty. Applications can then ask each other
for information with simple in-process messages. Messages are synchronous and
namespaced, and must be explicitly supported by Python web frameworks or their
extensions.BSD licensed. Install with:pip install wsgi_partyRead the docs at:http://readthedocs.org/docs/wsgi_party/This project started as a collaboration between Michael Merickel & Chris
McDonough (Pyramid core developers) and Ron DuPlain (a Flask core developer).
See AUTHORS for a full list of contributors.
Package: wsgi-pratchett
Simple WSGI middleware for adding Terry Pratchett’s header to your requests per
the conversation that’s happeningon redditUsageWSGI middleware is pretty simple.  Wrap your WSGI application in an instance ofGNUTerryPratchettand you’re set.frompratchettimportGNUTerryPratchett# ... your code here, create your WSGI applicationapp=GNUTerryPratchett(your_app)When using PasteDeploy configuration files you can also add the middleware there.# Your main application[app:main]filter-with=pratchett[filter:pratchett]use=egg:wsgi-pratchett
Package: wsgiprof
wsgiprof is a lightweight WSGI profiler with call graph visualization.ScreenshotUsageimportwsgiprofapplication=wsgiprof.ProfileMiddleware(application)Access to the application several times, and visit URL /__profile__
.Please note that graphviz is required to render call graph.Changelog1.0.1 (2016-06-15)Added Python3 support.1.0.0 (2015-09-02)First release.AuthorShuhei TakahashiWebsite:https://nya3.jp/Twitter:https://twitter.com/nya3jp/LicenseCopyright 2015 Shuhei Takahashi All Rights Reserved.Licensed under the Apache License, Version 2.0 (the “License”); you may
not use this file except in compliance with the License. You may obtain
a copy of the License athttp://www.apache.org/licenses/LICENSE-2.0Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an “AS IS” BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
Package: wsgi-proxy
This package implements a simple WSGI app that does HTTP 1.0 proxy.
You can install it usingpiporeasy_install:$pipinstallwsgi-proxyYou can run a proxy server usingwsgi-proxycommand it provides:$wsgi-proxy-p8080It provides a WSGI application object (wsgi_proxy:app) as well:$pipinstallgunicorn$gunicorn-p8080wsgi_proxy:appLinksDocshttps://wsgi-proxy.readthedocs.org/Bitbucket (Mercurial repository)https://bitbucket.org/dahlia/wsgi-proxyPackage Index (Cheeseshop)https://pypi.python.org/pypi/wsgi-proxy
Package: wsgiref
This is a standalone release of thewsgireflibrary, that provides
validation support for WSGI 1.0.1 (PEP 3333) for Python versions < 3.2,
and includes the newwsgiref.util.test()utility function.For this version’s documentation, see:HTMLhttp://peak.telecommunity.com/wsgiref_docs/PDFhttp://peak.telecommunity.com/wsgiref.pdf(You can also check out thedevelopment versionusingeasy_installwsgiref==dev.)
Package: wsgi-request-logger
This is a middleware which you can use to log requests to your WSGI
based site. It’s even imitating Apache’s combined log format to allow
you to use any of the many tools for Apache log file analysis.By making use of Python’s standard library logging facilities, you can
easily set it up to log to STDOUT, time rotated log files, email,
syslog, etc.InstallationSimply install this Python module viapip install wsgi-request-loggerUsageTo add this middleware to your WSGIapplicationand log to the fileaccess.log, do:from requestlogger import WSGILogger, ApacheFormatter
from logging.handlers import TimedRotatingFileHandler

def application(environ, start_response):
    response_body = 'The request method was %s' % environ['REQUEST_METHOD']
    response_body = response_body.encode('utf-8')
    response_headers = [('Content-Type', 'text/plain'),
                        ('Content-Length', str(len(response_body)))]
    start_response('200 OK', response_headers)
    return [response_body]

handlers = [ TimedRotatingFileHandler('access.log', 'd', 7) , ]
loggingapp = WSGILogger(application, handlers, ApacheFormatter())

if __name__ == '__main__':
    from wsgiref.simple_server import make_server
    http = make_server('', 8080, loggingapp)
    http.serve_forever()The AuthorsThis WSGI middleware was originally developed under the namewsgilogbyL. C. Rees.
It was forked byPhilipp Klausin 2013 to build a WSGI middleware
for request logging rather than exception handling and logging.LicenseThis software,wsgi-request-logger, is published under a3-clause BSD
license.Developers’ ResourcesTo read about your options for the logging handler, you may want to
readPython’s Logging
Cookbook.Documentation on Apache’s log format can be foundhere.TheWSGI- Web Server Gateway Interface - is defined inPEP
333with an update for
Python 3 inPEP 3333.General ReferencesPyPI’slisting of
wsgi-request-loggerThe source code for this Python module ishosted on
Github.A blog post with more background information and usage examples:wsgi-request-logger – Logging HTTP Requests With Any WSGI Web
Application like Flask, Bottle or
Django
Package: wsgirouter3-weasyprint
Weasyprintplugin forwsgirouter3UsageConfigure application to use plugindef_generator(html_id:str,context:Any)->str:# your choice of template engineapplication=wsgirouter3.WsgiApp(router)wsgirouter3_weasyprint.install(application,wsgirouter3_weasyprint.PdfConfig(html_generator=_generator))Return instance of Pdf from endpoint@router.get('/get',produces='application/pdf')defget()->Pdf:html_generation_ctx={'context':'variable'}returnPdf('html_template_id',html_generation_ctx)Installation$pipinstallwsgirouter3_weasyprint
Package: wsgirpc
WSGI-based RPCWhy this package?JSON-RPC is easy and fast, but you need to convert your arguments and return values to basic python types (strings, lists, dicts, etc)Pyro and RPyC are very powerful, but sometimes you don't need nor want every object to be proxied over sockets.This package provides the ability to invoque methods on a remote object with pickable arguments and receiving a pickable object on return.This module is about 70 lines of code and depends only on Python andrequestspackage.This implementation is supposed to be fast while being easy to understand.Running the included exampleThe included example implements a program that mimics the Linuxrevcommand.
The client program runs a loop that reads a line of text from stdin, sends it to
the server which reverses it and returns it back to the client, which prints it to stdout.To run the example server with Python's wsgi reference implemetantion:$ python example/server.pyTo run the example server with gunicorn:$ cd example && gunicorn -b localhost:5555 server:appTo run the client:$ echo Hello world | python example/client.py
dlrow olleHLicenseThis Python module is licensed under the MIT license.