diff --git a/404.html b/404.html new file mode 100644 index 0000000..4d1dc3c --- /dev/null +++ b/404.html @@ -0,0 +1,74 @@ + + + + + File uploader + + + + + + +
+

File uploader

+ +
+
+

404

+

Hmmm... It looks like the file has not been found.

+
+
+ + \ No newline at end of file diff --git a/main.py b/main.py index 381cda9..bd9e7f8 100644 --- a/main.py +++ b/main.py @@ -1,3 +1,8 @@ +""" +created by AndcoolSystems, 2023-2024 +""" + + from fastapi import FastAPI, UploadFile, Request, Header from fastapi.responses import JSONResponse, FileResponse, Response from typing import Annotated, Union @@ -90,7 +95,6 @@ async def upload_file(file: UploadFile, request: Request, include_ext: bool = Fa user_id = -1 saved_to_account = False - auth_error = {} token_db, auth_error = await check_token(Authorization) # Check token if token_db: # If token is okay @@ -136,9 +140,11 @@ async def upload_file(file: UploadFile, request: Request, include_ext: bool = Fa @app.get("/file/{url}") # Get file handler @limiter.limit(f"10/minute") async def send_file(url: str, request: Request): - result = await db.file.find_first(where={"url": url}) # Get file by url - if not result: return JSONResponse(content="File not found!", status_code=404) # if file does'n exists + if not result: + async with aiofiles.open("404.html", mode="rb") as f: + return Response(await f.read(), media_type="text/html", status_code=404) # if file does'n exists + print(request.headers.get('CF-IPCountry')) if 'sec-fetch-dest' in request.headers: diff --git a/web/script.js b/web/script.js index ee20c82..63727f7 100644 --- a/web/script.js +++ b/web/script.js @@ -33,9 +33,9 @@ function append_to_files_arr(data, id){ let url = document.createElement("a"); url.innerHTML = data['file_url_full']; url.id = "url"; - //url.onclick = function(){navigator.clipboard.writeText(data['file_url_full']);} - url.href = data['file_url_full']; - url.target = "_blank"; + url.onclick = function(){navigator.clipboard.writeText(data['file_url_full']);} + //url.href = data['file_url_full']; + //url.target = "_blank"; let filename = document.createElement("p"); filename.innerHTML = data['user_filename']; diff --git a/web/snowflakes.js b/web/snowflakes.js index c0eed48..6ebd5ca 100644 --- a/web/snowflakes.js +++ b/web/snowflakes.js @@ -19,6 +19,7 @@ class Circle{ this.last_set = 1; this.random_time = getRandomInt(1000, 5000); this.random_sin_mod = getRandomInt(1, 3); + this.last_scroll = document.documentElement.scrollTop || document.body.scrollTop; } tick(){ @@ -27,9 +28,13 @@ class Circle{ const circle = this.object; this.posY += this.speedY; this.posX += Math.sin(now_time / 1000) * this.random_sin_mod; + if (this.posY > this.vh){ this.posY = getRandomInt(-this.vw, -50); } - if (this.posX > this.vw){ this.posX = -50; } + if (this.posX > this.vw){ + this.posX = -10; + } if (this.posX < -10){ this.posX = this.vw; } + this.posY -= (document.documentElement.scrollTop || document.body.scrollTop) - this.last_scroll; if (now_time - this.last_time > this.random_time){ this.last_time = now_time; @@ -39,8 +44,7 @@ class Circle{ circle.style.left = this.posX + 'px'; circle.style.top = this.posY + 'px'; - //circle.style.width = "5px"; - //circle.style.height = "5px"; + this.last_scroll = document.documentElement.scrollTop || document.body.scrollTop; } } @@ -48,7 +52,7 @@ function run_anim(){ let table = document.getElementById('canvas'); let vw = Math.max(document.documentElement.clientWidth || 0, window.innerWidth || 0); let count = 30//Math.round(vw * vh / 10000); - + table.style.display = "block"; const date = new Date(); let day = date.getDate(); @@ -58,7 +62,7 @@ function run_anim(){ snow_btn.style.display = "none"; return; } - if( localStorage.getItem("disable_snow")){ + if( localStorage.getItem("disable_snow") ){ return; } @@ -67,21 +71,23 @@ function run_anim(){ snowflake.innerHTML = "*"; snowflake.className = "snowflake"; table.appendChild(snowflake); - object_array.push(new Circle(snowflake)) + object_array.push(new Circle(snowflake)); + } - - function tick(){ - for (const snowflake of object_array){ - snowflake.tick(); - } +} +function tick(){ + for (const snowflake of object_array){ + snowflake.tick(); } - - setInterval(tick, 16); } +setInterval(tick, 16); + + function stop_anim(){ object_array = []; let table = document.getElementById('canvas'); + table.innerHTML = ""; table.style.display = "none"; } diff --git a/web/style.css b/web/style.css index f7e616a..4aa3433 100644 --- a/web/style.css +++ b/web/style.css @@ -206,7 +206,7 @@ nav a:hover{ #canvas{ overflow: hidden; - position: absolute; + position: fixed; width: 100%; height: 100%; pointer-events: none;