2016-10-16 08:50:49 +01:00
|
|
|
# Run with: python3 -O simple_server.py
|
|
|
|
import asyncio
|
|
|
|
import logging
|
2019-04-23 22:44:42 +01:00
|
|
|
|
2016-10-16 08:50:49 +01:00
|
|
|
import ujson
|
|
|
|
import uvloop
|
|
|
|
|
2019-04-23 22:44:42 +01:00
|
|
|
from kyoukai import HTTPRequestContext, Kyoukai
|
|
|
|
|
|
|
|
|
2016-10-16 08:50:49 +01:00
|
|
|
loop = uvloop.new_event_loop()
|
|
|
|
asyncio.set_event_loop(loop)
|
|
|
|
|
|
|
|
kyk = Kyoukai("example_app")
|
|
|
|
|
|
|
|
logger = logging.getLogger("Kyoukai")
|
|
|
|
logger.setLevel(logging.ERROR)
|
|
|
|
|
2018-12-30 11:18:06 +00:00
|
|
|
|
2016-10-16 08:50:49 +01:00
|
|
|
@kyk.route("/")
|
|
|
|
async def index(ctx: HTTPRequestContext):
|
2018-12-30 11:18:06 +00:00
|
|
|
return (
|
|
|
|
ujson.dumps({"test": True}),
|
|
|
|
200,
|
|
|
|
{"Content-Type": "application/json"},
|
|
|
|
)
|
|
|
|
|
2016-10-16 08:50:49 +01:00
|
|
|
|
2018-12-30 11:18:06 +00:00
|
|
|
kyk.run()
|