Search Options

Results per page
Sort
Preferred Languages
Advance

Results 1 - 10 of 40 for html (0.14 sec)

  1. docs_src/custom_response/tutorial004.py

    from fastapi.responses import HTMLResponse
    
    app = FastAPI()
    
    
    def generate_html_response():
        html_content = """
        <html>
            <head>
                <title>Some HTML in here</title>
            </head>
            <body>
                <h1>Look ma! HTML!</h1>
            </body>
        </html>
        """
        return HTMLResponse(content=html_content, status_code=200)
    
    
    @app.get("/items/", response_class=HTMLResponse)
    Python
    - Registered: Sun Apr 21 07:19:11 GMT 2024
    - Last Modified: Thu Mar 26 19:09:53 GMT 2020
    - 491 bytes
    - Viewed (0)
  2. docs_src/custom_docs_ui/tutorial001.py

    from fastapi import FastAPI
    from fastapi.openapi.docs import (
        get_redoc_html,
        get_swagger_ui_html,
        get_swagger_ui_oauth2_redirect_html,
    )
    
    app = FastAPI(docs_url=None, redoc_url=None)
    
    
    @app.get("/docs", include_in_schema=False)
    async def custom_swagger_ui_html():
        return get_swagger_ui_html(
            openapi_url=app.openapi_url,
            title=app.title + " - Swagger UI",
    Python
    - Registered: Sun Apr 21 07:19:11 GMT 2024
    - Last Modified: Mon Oct 30 09:58:58 GMT 2023
    - 1.1K bytes
    - Viewed (0)
  3. docs_src/custom_docs_ui/tutorial002.py

    from fastapi.openapi.docs import (
        get_redoc_html,
        get_swagger_ui_html,
        get_swagger_ui_oauth2_redirect_html,
    )
    from fastapi.staticfiles import StaticFiles
    
    app = FastAPI(docs_url=None, redoc_url=None)
    
    app.mount("/static", StaticFiles(directory="static"), name="static")
    
    
    @app.get("/docs", include_in_schema=False)
    async def custom_swagger_ui_html():
        return get_swagger_ui_html(
            openapi_url=app.openapi_url,
    Python
    - Registered: Sun Apr 21 07:19:11 GMT 2024
    - Last Modified: Sat Aug 19 19:54:04 GMT 2023
    - 1.1K bytes
    - Viewed (0)
  4. tests/test_tutorial/test_websockets/test_tutorial003_py39.py

    
    @pytest.fixture(name="html")
    def get_html():
        from docs_src.websockets.tutorial003_py39 import html
    
        return html
    
    
    @pytest.fixture(name="client")
    def get_client(app: FastAPI):
        client = TestClient(app)
    
        return client
    
    
    @needs_py39
    def test_get(client: TestClient, html: str):
        response = client.get("/")
        assert response.text == html
    
    
    @needs_py39
    Python
    - Registered: Sun Apr 21 07:19:11 GMT 2024
    - Last Modified: Sat Mar 18 12:29:59 GMT 2023
    - 1.3K bytes
    - Viewed (0)
  5. tests/test_default_response_class_router.py

    app.include_router(
        router_b_override, prefix="/b", default_response_class=PlainTextResponse
    )
    
    
    client = TestClient(app)
    
    json_type = "application/json"
    text_type = "text/plain; charset=utf-8"
    html_type = "text/html; charset=utf-8"
    override_type = "application/x-override"
    
    
    def test_app():
        with client:
            response = client.get("/")
        assert response.json() == {"msg": "Hello World"}
    Python
    - Registered: Sun Apr 21 07:19:11 GMT 2024
    - Last Modified: Sun Mar 01 20:49:20 GMT 2020
    - 5K bytes
    - Viewed (0)
  6. tests/test_tutorial/test_websockets/test_tutorial003.py

    from fastapi.testclient import TestClient
    
    from docs_src.websockets.tutorial003 import app, html
    
    client = TestClient(app)
    
    
    def test_get():
        response = client.get("/")
        assert response.text == html
    
    
    def test_websocket_handle_disconnection():
        with client.websocket_connect("/ws/1234") as connection, client.websocket_connect(
            "/ws/5678"
        ) as connection_two:
            connection.send_text("Hello from 1234")
    Python
    - Registered: Sun Apr 21 07:19:11 GMT 2024
    - Last Modified: Thu Jul 29 09:26:07 GMT 2021
    - 872 bytes
    - Viewed (0)
  7. tests/test_tutorial/test_websockets/test_tutorial001.py

    from docs_src.websockets.tutorial001 import app
    
    client = TestClient(app)
    
    
    def test_main():
        response = client.get("/")
        assert response.status_code == 200, response.text
        assert b"<!DOCTYPE html>" in response.content
    
    
    def test_websocket():
        with pytest.raises(WebSocketDisconnect):
            with client.websocket_connect("/ws") as websocket:
                message = "Message one"
    Python
    - Registered: Sun Apr 21 07:19:11 GMT 2024
    - Last Modified: Fri Jul 10 09:08:19 GMT 2020
    - 822 bytes
    - Viewed (0)
  8. tests/test_tutorial/test_metadata/test_tutorial001.py

                    "email": "******@****.***",
                },
                "license": {
                    "name": "Apache 2.0",
                    "url": "https://www.apache.org/licenses/LICENSE-2.0.html",
                },
                "version": "0.0.1",
            },
            "paths": {
                "/items/": {
                    "get": {
                        "summary": "Read Items",
    Python
    - Registered: Sun Apr 21 07:19:11 GMT 2024
    - Last Modified: Fri Jun 30 18:25:16 GMT 2023
    - 1.7K bytes
    - Viewed (0)
  9. tests/test_tutorial/test_websockets/test_tutorial002_an_py39.py

        return app
    
    
    @needs_py39
    def test_main(app: FastAPI):
        client = TestClient(app)
        response = client.get("/")
        assert response.status_code == 200, response.text
        assert b"<!DOCTYPE html>" in response.content
    
    
    @needs_py39
    def test_websocket_with_cookie(app: FastAPI):
        client = TestClient(app, cookies={"session": "fakesession"})
        with pytest.raises(WebSocketDisconnect):
    Python
    - Registered: Sun Apr 21 07:19:11 GMT 2024
    - Last Modified: Sat Mar 18 12:29:59 GMT 2023
    - 3.9K bytes
    - Viewed (0)
  10. docs_src/websockets/tutorial002_py310.py

    from fastapi import (
        Cookie,
        Depends,
        FastAPI,
        Query,
        WebSocket,
        WebSocketException,
        status,
    )
    from fastapi.responses import HTMLResponse
    
    app = FastAPI()
    
    html = """
    <!DOCTYPE html>
    <html>
        <head>
            <title>Chat</title>
        </head>
        <body>
            <h1>WebSocket Chat</h1>
            <form action="" onsubmit="sendMessage(event)">
    Python
    - Registered: Sun Apr 21 07:19:11 GMT 2024
    - Last Modified: Sat Mar 18 12:29:59 GMT 2023
    - 2.7K bytes
    - Viewed (0)
Back to top