Ejemplo n.º 1
0
def serve(reload=False):
    """Run a web server (for development only)."""
    # Debug only.
    static(app, "/explorer/", Path(__file__).parent / "explorer")
    if reload:
        hupper.start_reloader("trefle.bin.serve")
    traceback(app)
    simple_server(app)
Ejemplo n.º 2
0
def serve(reload=False):
    """Run a web server (for development only)."""
    if reload:
        import hupper

        hupper.start_reloader("copanier.serve")
    static(app, root=Path(__file__).parent / "static")
    simple_server(app, port=2244)
Ejemplo n.º 3
0
def serve(reload=False):
    """Run a web server (for development only)."""
    from roll.extensions import simple_server

    from .views import app

    if reload:
        import hupper

        hupper.start_reloader("egapro.bin.serve")
    simple_server(app, port=2626)
Ejemplo n.º 4
0
import asyncio
import os

import uvloop
from aiofile import AIOFile, Reader
from roll import Roll
from roll.extensions import cors, igniter, logger, simple_server, traceback

asyncio.set_event_loop_policy(uvloop.EventLoopPolicy())

app = Roll()
cors(app)
logger(app)
traceback(app)


@app.route("/fullasync", methods=["POST"], lazy_body=True)
async def fullasync(request, response):
    response.body = (chunk async for chunk in request)


if __name__ == "__main__":
    simple_server(app)
Ejemplo n.º 5
0
            message += f" [envoyé depuis {parse(user_agent)}]"

        if request.host.startswith("127.0.0.1"):
            print(message)
        else:
            await request.app.bot.send_message(message)

        response.status = HTTPStatus.ACCEPTED
        response.json = {"message": message}


@app.listen("error")
async def json_error_response(request, response, error):
    if isinstance(error.message, str):
        error.message = {"error": error.message}
    elif isinstance(error.message, bytes):
        error.message = {"error": error.message.decode("utf-8")}
    response.json = error.message
    if error.status != HTTPStatus.NOT_FOUND:
        logger.debug(
            f"HttpError: status={error.status}, message={response.body}, "
            f"request={request.body.decode('utf-8')}, "
            f"url={request.url.decode('utf-8')}")


if __name__ == "__main__":
    logging.basicConfig(level=logging.DEBUG)
    simple_server(app,
                  host=os.environ.get("HOST", "127.0.0.1"),
                  port=os.environ.get("PORT", 5678))
Ejemplo n.º 6
0
def run() -> None:
    simple_server(app)