Changed static folder path

This commit is contained in:
2023-09-11 23:57:25 +04:00
parent cec971e0ae
commit 77e4722576
18 changed files with 52 additions and 10 deletions

View File

@@ -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'),

View File

@@ -34,7 +34,7 @@ app = FastAPI(
# app.mount(
# '/static',
# StaticFiles(directory=settings.APP_PATH / 'static'),
# StaticFiles(directory=settings.MAIN_PATH / 'static'),
# name='static'
# )

File diff suppressed because it is too large Load Diff

File diff suppressed because one or more lines are too long

Binary file not shown.

File diff suppressed because one or more lines are too long

File diff suppressed because it is too large Load Diff

Before

Width:  |  Height:  |  Size: 434 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 190 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.5 KiB

View File

@@ -1,36 +0,0 @@
(function() {
"use strict"; // Start of use strict
// Show the navbar when the page is scrolled up
var MQL = 992;
var vw = Math.max(document.documentElement.clientWidth || 0, window.innerWidth || 0);
var mainNav = document.querySelector('#mainNav');
//primary navigation slide-in effect
if (mainNav && vw > MQL) {
var headerHeight = mainNav.offsetHeight;
var previousTop = window.pageYOffset;
window.addEventListener('scroll', function() {
var currentTop = window.pageYOffset;
//check if user is scrolling up
if (currentTop < previousTop) {
//if scrolling up...
if (currentTop > 0 && mainNav.classList.contains('is-fixed')) {
mainNav.classList.add('is-visible');
} else {
mainNav.classList.remove('is-visible', 'is-fixed');
}
} else if (currentTop > previousTop) {
//if scrolling down...
mainNav.classList.remove('is-visible');
if (currentTop > headerHeight && !mainNav.classList.contains('is-fixed')) {
mainNav.classList.add('is-fixed');
}
}
previousTop = currentTop;
});
}
})(); // End of use strict

View File

@@ -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> -->

View File

@@ -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')