Skip to content

FastAPI | Cookbook

  • Ralph 

Einleitung

Anforderungen

Inhaltsverzeichnis

CORS

app = FastAPI()
app.add_middleware(
    CORSMiddleware,
    allow_origins=["*"],
    allow_credentials=True,
    allow_methods=["*"],
    allow_headers=["*"]
)

Starlette

Templates

Template erstellen

...

    {% block content %}{% endblock %}
...

Template verwenden

{% extends "base.html" %}

{% block content %}
    ...
    <main>....</main>
{% endblock %}

Links

CSS

<link href="{{ url_for('static', path='/css/bootstrap.min.css') }}"
      rel="stylesheet"
>

JavaScript

<script src="{{ url_for('static', path='/js/jquery.min.js') }}"></script>

Leave a Reply

Your email address will not be published. Required fields are marked *