ccd4c9615c
Update all tests to be compatible with requests-async Cleanup testing client changes with black and isort Remove Python 3.5 and other meta doc cleanup rename pyproject and fix pep517 error Add black config to tox.ini Cleanup tests and remove aiohttp tox.ini change for easier development commands Remove aiohttp from changelog and requirements Cleanup imports and Makefile
50 lines
1.2 KiB
Python
50 lines
1.2 KiB
Python
# Run with: gunicorn --workers=1 --worker-class=meinheld.gmeinheld.MeinheldWorker simple_server:main
|
|
""" Minimal helloworld application.
|
|
"""
|
|
|
|
import ujson
|
|
|
|
from wheezy.http import HTTPResponse, WSGIApplication
|
|
from wheezy.http.response import json_response
|
|
from wheezy.routing import url
|
|
from wheezy.web.handlers import BaseHandler
|
|
from wheezy.web.middleware import (
|
|
bootstrap_defaults,
|
|
path_routing_middleware_factory,
|
|
)
|
|
|
|
|
|
class WelcomeHandler(BaseHandler):
|
|
def get(self):
|
|
response = HTTPResponse(content_type="application/json; charset=UTF-8")
|
|
response.write(ujson.dumps({"test": True}))
|
|
return response
|
|
|
|
|
|
all_urls = [
|
|
url("", WelcomeHandler, name="default"),
|
|
# url('', welcome, name='welcome')
|
|
]
|
|
|
|
|
|
options = {}
|
|
main = WSGIApplication(
|
|
middleware=[
|
|
bootstrap_defaults(url_mapping=all_urls),
|
|
path_routing_middleware_factory,
|
|
],
|
|
options=options,
|
|
)
|
|
|
|
|
|
if __name__ == "__main__":
|
|
import sys
|
|
from wsgiref.simple_server import make_server
|
|
|
|
try:
|
|
print("Visit http://localhost:{}/".format(sys.argv[-1]))
|
|
make_server("", int(sys.argv[-1]), main).serve_forever()
|
|
except KeyboardInterrupt:
|
|
pass
|
|
print("\nThanks!")
|