Changed static folder path
@ -21,7 +21,7 @@ services:
|
|||||||
- db
|
- db
|
||||||
volumes:
|
volumes:
|
||||||
- ./src/app:/src/app
|
- ./src/app:/src/app
|
||||||
- static:/src/app/static
|
- static:/src/static
|
||||||
- media:/src/media
|
- media:/src/media
|
||||||
command: >
|
command: >
|
||||||
bash -c "poetry run alembic upgrade head
|
bash -c "poetry run alembic upgrade head
|
||||||
|
@ -15,6 +15,8 @@ class Settings(BaseSettings):
|
|||||||
APP_PATH: Path = MAIN_PATH / 'app' # path to app folder
|
APP_PATH: Path = MAIN_PATH / 'app' # path to app folder
|
||||||
MEDIA_FOLDER: Path = Path('media') # name of media folder
|
MEDIA_FOLDER: Path = Path('media') # name of media folder
|
||||||
MEDIA_PATH: Path = MAIN_PATH / MEDIA_FOLDER # path to 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] = {
|
FILE_FOLDERS: dict[str, Path] = {
|
||||||
'post_images': Path('post_images'),
|
'post_images': Path('post_images'),
|
||||||
|
@ -34,7 +34,7 @@ app = FastAPI(
|
|||||||
|
|
||||||
# app.mount(
|
# app.mount(
|
||||||
# '/static',
|
# '/static',
|
||||||
# StaticFiles(directory=settings.APP_PATH / 'static'),
|
# StaticFiles(directory=settings.MAIN_PATH / 'static'),
|
||||||
# name='static'
|
# name='static'
|
||||||
# )
|
# )
|
||||||
|
|
||||||
|
@ -34,3 +34,44 @@
|
|||||||
</body>
|
</body>
|
||||||
|
|
||||||
</html>
|
</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 sqlalchemy.ext.asyncio import AsyncSession
|
||||||
|
|
||||||
from fastapi.templating import Jinja2Templates
|
from fastapi.templating import Jinja2Templates
|
||||||
from fastapi.responses import HTMLResponse
|
from fastapi.responses import FileResponse, HTMLResponse
|
||||||
from fastapi import (
|
from fastapi import (
|
||||||
APIRouter,
|
APIRouter,
|
||||||
HTTPException,
|
HTTPException,
|
||||||
@ -45,7 +45,7 @@ async def login(
|
|||||||
async def login(
|
async def login(
|
||||||
db: AsyncSession = Depends(get_async_db),
|
db: AsyncSession = Depends(get_async_db),
|
||||||
form_data: LoginForm = Depends()
|
form_data: LoginForm = Depends()
|
||||||
) -> Any:
|
):
|
||||||
|
|
||||||
user = await crud.user.authenticate(
|
user = await crud.user.authenticate(
|
||||||
db, email=form_data.email, password=form_data.password
|
db, email=form_data.email, password=form_data.password
|
||||||
@ -68,10 +68,9 @@ async def login(
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
# @router.get("/test")
|
@router.get("/admin")
|
||||||
# def test(
|
def admin(
|
||||||
# request: Request,
|
request: Request
|
||||||
# user: UserModel = Depends(get_current_active_superuser),
|
):
|
||||||
# ) -> Any:
|
|
||||||
|
|
||||||
# return user.email
|
return FileResponse(settings.STATIC_FOLDER / 'just_a.gif')
|
Before Width: | Height: | Size: 434 KiB After Width: | Height: | Size: 434 KiB |
Before Width: | Height: | Size: 190 KiB After Width: | Height: | Size: 190 KiB |
Before Width: | Height: | Size: 4.5 KiB After Width: | Height: | Size: 4.5 KiB |
BIN
src/static/just_a.gif
Normal file
After Width: | Height: | Size: 2.2 MiB |