mirror of
https://github.com/aykhans/portfolio-blog.git
synced 2026-10-21 17:48:29 +00:00
Changed static folder path
This commit is contained in:
1 parent
cec971e0ae
commit
77e4722576
18 files changed
+52
-10
No files matched your search
@@ -15,6 +15,8 @@ class Settings(BaseSettings):
|
||||
APP_PATH: Path = MAIN_PATH / 'app' # path to app folder
|
||||
MEDIA_FOLDER: Path = Path('media') # name of media folder
|
||||
MEDIA_PATH: Path = MAIN_PATH / MEDIA_FOLDER # path to media folder
|
||||
STATIC_FOLDER_NAME: Path = Path('static') # name of static folder
|
||||
STATIC_FOLDER: Path = MAIN_PATH / STATIC_FOLDER_NAME # path to static folder
|
||||
|
||||
FILE_FOLDERS: dict[str, Path] = {
|
||||
'post_images': Path('post_images'),
|
||||
|
||||
+1
-1
@@ -34,7 +34,7 @@ app = FastAPI(
|
||||
|
||||
# app.mount(
|
||||
# '/static',
|
||||
# StaticFiles(directory=settings.APP_PATH / 'static'),
|
||||
# StaticFiles(directory=settings.MAIN_PATH / 'static'),
|
||||
# name='static'
|
||||
# )
|
||||
|
||||
|
||||
@@ -34,3 +34,44 @@
|
||||
</body>
|
||||
|
||||
</html>
|
||||
|
||||
<!-- <!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<title>Login Example</title>
|
||||
</head>
|
||||
<body>
|
||||
<form id="loginForm">
|
||||
<input type="text" name="email" placeholder="email">
|
||||
<input type="password" name="password" placeholder="Password">
|
||||
<button type="submit">Login</button>
|
||||
</form>
|
||||
|
||||
<script>
|
||||
// Function to handle the form submission
|
||||
function handleSubmit(event) {
|
||||
event.preventDefault();
|
||||
const form = document.getElementById('loginForm');
|
||||
const formData = new FormData(form);
|
||||
|
||||
fetch('/login', {
|
||||
method: 'POST', // Adjust the HTTP method if needed
|
||||
body: formData,
|
||||
})
|
||||
.then(response => response.json())
|
||||
.then(data => {
|
||||
const accessToken = data.access_token;
|
||||
console.log(accessToken);
|
||||
document.cookie = `access_token=${accessToken}`;
|
||||
})
|
||||
.catch(error => {
|
||||
console.error('Login error:', error);
|
||||
});
|
||||
}
|
||||
|
||||
// Add a submit event listener to the form
|
||||
const loginForm = document.getElementById('loginForm');
|
||||
loginForm.addEventListener('submit', handleSubmit);
|
||||
</script>
|
||||
</body>
|
||||
</html> -->
|
||||
@@ -4,7 +4,7 @@ from datetime import timedelta
|
||||
from sqlalchemy.ext.asyncio import AsyncSession
|
||||
|
||||
from fastapi.templating import Jinja2Templates
|
||||
from fastapi.responses import HTMLResponse
|
||||
from fastapi.responses import FileResponse, HTMLResponse
|
||||
from fastapi import (
|
||||
APIRouter,
|
||||
HTTPException,
|
||||
@@ -45,7 +45,7 @@ async def login(
|
||||
async def login(
|
||||
db: AsyncSession = Depends(get_async_db),
|
||||
form_data: LoginForm = Depends()
|
||||
) -> Any:
|
||||
):
|
||||
|
||||
user = await crud.user.authenticate(
|
||||
db, email=form_data.email, password=form_data.password
|
||||
@@ -68,10 +68,9 @@ async def login(
|
||||
}
|
||||
|
||||
|
||||
# @router.get("/test")
|
||||
# def test(
|
||||
# request: Request,
|
||||
# user: UserModel = Depends(get_current_active_superuser),
|
||||
# ) -> Any:
|
||||
@router.get("/admin")
|
||||
def admin(
|
||||
request: Request
|
||||
):
|
||||
|
||||
# return user.email
|
||||
return FileResponse(settings.STATIC_FOLDER / 'just_a.gif')
|
||||
Vendored
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Binary file not shown.
|
After Width: | Height: | Size: 2.2 MiB |
Reference in new issue
Block a user