Skip to content

Commit 8a2cf61

Browse files
committed
Mount staticfiles for social icons
1 parent af2889e commit 8a2cf61

File tree

4 files changed

+18
-3
lines changed

4 files changed

+18
-3
lines changed

examples/demonstration/main.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
from fastapi import APIRouter
22
from fastapi import FastAPI
3+
from fastapi.staticfiles import StaticFiles
34
from sqlalchemy.orm import Session
45

56
from config import oauth2_config
@@ -37,4 +38,5 @@ async def on_auth(auth: Auth, user: User):
3738
app = FastAPI()
3839
app.include_router(app_router)
3940
app.include_router(oauth2_router)
41+
app.mount("/static", StaticFiles(directory="static"), name="static")
4042
app.add_middleware(OAuth2Middleware, config=oauth2_config, callback=on_auth)
Lines changed: 5 additions & 0 deletions
Loading
Lines changed: 6 additions & 0 deletions
Loading

examples/demonstration/templates/index.html

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,11 @@
2323
</a>
2424
{% for provider in request.auth.clients %}
2525
<a href="/oauth2/{{ provider }}/auth" style="display: flex; align-items: center;">
26-
<svg style="height: 50px; width: 50px;" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 16 16">
27-
<path fill="#dfdfd6" d="M7.499,1C3.91,1,1,3.906,1,7.49c0,2.867,1.862,5.299,4.445,6.158C5.77,13.707,6,13.375,6,13.125 c0-0.154,0.003-0.334,0-0.875c-1.808,0.392-2.375-0.875-2.375-0.875c-0.296-0.75-0.656-0.963-0.656-0.963 c-0.59-0.403,0.044-0.394,0.044-0.394C3.666,10.064,4,10.625,4,10.625c0.5,0.875,1.63,0.791,2,0.625 c0-0.397,0.044-0.688,0.154-0.873C4.111,10.02,2.997,8.84,3,7.208c0.002-0.964,0.335-1.715,0.876-2.269 C3.639,4.641,3.479,3.625,3.961,3c1.206,0,1.927,0.873,1.927,0.873s0.565-0.248,1.61-0.248c1.045,0,1.608,0.234,1.608,0.234 S9.829,3,11.035,3c0.482,0.625,0.322,1.641,0.132,1.918C11.684,5.461,12,6.21,12,7.208c0,1.631-1.11,2.81-3.148,3.168 C8.982,10.572,9,10.842,9,11.25c0,0.867,0,1.662,0,1.875c0,0.25,0.228,0.585,0.558,0.522C12.139,12.787,14,10.356,14,7.49 C14,3.906,11.09,1,7.499,1z"></path>
28-
</svg>
26+
<img
27+
alt="{{ provider }} icon"
28+
src="/static/{{ provider }}.svg"
29+
style="width: 50px; height: 50px; margin-right: 1rem;"
30+
>
2931
</a>
3032
{% endfor %}
3133
{% endif %}

0 commit comments

Comments
 (0)