Compare commits
2
Commits
4a2974098f
...
57a73e9c17
No files matched your search
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
@@ -1,4 +1,4 @@
|
|||||||
import uvicorn
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
|
import uvicorn
|
||||||
|
|
||||||
uvicorn.run("uhhhhup:app", host="0.0.0.0", port=2222, reload=True)
|
uvicorn.run("uhhhhup:app", host="0.0.0.0", port=2222, reload=True)
|
||||||
+1
-1
@@ -122,7 +122,7 @@ li a {
|
|||||||
justify-content: center;
|
justify-content: center;
|
||||||
width: 100%;
|
width: 100%;
|
||||||
max-width: 1000px;
|
max-width: 1000px;
|
||||||
margin-bottom: 40px;
|
margin-bottom: 20px;
|
||||||
}
|
}
|
||||||
|
|
||||||
.card {
|
.card {
|
||||||
|
|||||||
+20
-1
@@ -34,7 +34,26 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
<div class="card" style="margin-block: 1em">
|
||||||
|
<h2>Scan this page</h2>
|
||||||
|
<p>Connect your phone to the same Wi-Fi and scan this.</p>
|
||||||
|
<div
|
||||||
|
class="qrcode"
|
||||||
|
style="padding: 1rem; background: white; border-radius: 8px"
|
||||||
|
id="page_url"
|
||||||
|
></div>
|
||||||
|
<script src="https://cdn.jsdelivr.net/npm/[email protected]/qrcode.js"></script>
|
||||||
|
<script>
|
||||||
|
new QRCode(document.getElementById("page_url"), {
|
||||||
|
text: "{{ page_url }}",
|
||||||
|
width: 256,
|
||||||
|
height: 256,
|
||||||
|
colorDark: "#000000",
|
||||||
|
colorLight: "#ffffff",
|
||||||
|
correctLevel: QRCode.CorrectLevel.L,
|
||||||
|
});
|
||||||
|
</script>
|
||||||
|
</div>
|
||||||
<details>
|
<details>
|
||||||
<summary>System Routes</summary>
|
<summary>System Routes</summary>
|
||||||
<div class="route-list">
|
<div class="route-list">
|
||||||
|
|||||||
@@ -4,6 +4,10 @@
|
|||||||
<meta charset="UTF-8" />
|
<meta charset="UTF-8" />
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||||
<title>Queue dump type shit</title>
|
<title>Queue dump type shit</title>
|
||||||
|
<link
|
||||||
|
rel="stylesheet"
|
||||||
|
href="{{ url_for('static', path='style.css') }}"
|
||||||
|
/>
|
||||||
</head>
|
</head>
|
||||||
|
|
||||||
<body>
|
<body>
|
||||||
|
|||||||
@@ -0,0 +1,22 @@
|
|||||||
|
<!DOCTYPE html>
|
||||||
|
<html lang="en">
|
||||||
|
<head>
|
||||||
|
<meta charset="UTF-8" />
|
||||||
|
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||||
|
<title>paste pad</title>
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<input id="n" />
|
||||||
|
<textarea id="pc"></textarea>
|
||||||
|
<button type="button" id="s">sendit</button>
|
||||||
|
<script>
|
||||||
|
/** @type {HTMLInputElement} */
|
||||||
|
const name = document.getElementById("n");
|
||||||
|
/** @type {HTMLTextAreaElement} */
|
||||||
|
const content = document.getElementById("pc");
|
||||||
|
|
||||||
|
/** @type {HTMLButtonElement} */
|
||||||
|
(document.getElementById("s")).addEventListener("click", () => {});
|
||||||
|
</script>
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
+6
-5
@@ -4,15 +4,16 @@
|
|||||||
<meta charset="UTF-8" />
|
<meta charset="UTF-8" />
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||||
<title>QRCode queue</title>
|
<title>QRCode queue</title>
|
||||||
|
<link
|
||||||
|
rel="stylesheet"
|
||||||
|
href="{{ url_for('static', path='style.css') }}"
|
||||||
|
/>
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
{% from "macros.html" import qrcode_queue %}
|
{% from "macros.html" import qrcode_queue %} {% if queue_items %}
|
||||||
{% if queue_items %}
|
|
||||||
<p>total: {{ queue_items|length }}</p>
|
<p>total: {{ queue_items|length }}</p>
|
||||||
{{ qrcode_queue(queue_items) }}
|
{{ qrcode_queue(queue_items) }} {% else %}
|
||||||
{% else %}
|
|
||||||
<p>empty</p>
|
<p>empty</p>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
@@ -59,10 +59,13 @@
|
|||||||
newTab.document.body.style.backgroundColor =
|
newTab.document.body.style.backgroundColor =
|
||||||
getComputedStyle(document.body).backgroundColor;
|
getComputedStyle(document.body).backgroundColor;
|
||||||
|
|
||||||
const f =
|
document
|
||||||
document.querySelector(".trail-container");
|
.querySelectorAll("body > *:not(script)")
|
||||||
if (f)
|
.forEach((f) =>
|
||||||
newTab.document.body.innerHTML += f.outerHTML;
|
newTab.document.body.appendChild(
|
||||||
|
f.cloneNode(true)
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
// maybe just replace the whole document with this one and then use API to check length
|
// maybe just replace the whole document with this one and then use API to check length
|
||||||
// i aint doing that
|
// i aint doing that
|
||||||
@@ -79,6 +82,7 @@
|
|||||||
)
|
)
|
||||||
);
|
);
|
||||||
newTab.document.adoptedStyleSheets.push(st);
|
newTab.document.adoptedStyleSheets.push(st);
|
||||||
|
newTab.document.close();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|||||||
+80
-2
@@ -1,10 +1,13 @@
|
|||||||
"gemini converted"
|
"gemini converted"
|
||||||
|
|
||||||
|
from random import choice
|
||||||
|
import socket
|
||||||
from collections import deque
|
from collections import deque
|
||||||
from itertools import islice
|
from itertools import islice
|
||||||
|
import string
|
||||||
|
from typing import Optional
|
||||||
from urllib.parse import urlsplit, urlunsplit
|
from urllib.parse import urlsplit, urlunsplit
|
||||||
|
|
||||||
import uvicorn
|
|
||||||
from fastapi import FastAPI, Form, Request
|
from fastapi import FastAPI, Form, Request
|
||||||
from fastapi.responses import HTMLResponse, RedirectResponse
|
from fastapi.responses import HTMLResponse, RedirectResponse
|
||||||
from fastapi.staticfiles import StaticFiles
|
from fastapi.staticfiles import StaticFiles
|
||||||
@@ -16,6 +19,19 @@ templates = Jinja2Templates(directory="templates")
|
|||||||
queue: deque[str] = deque() # fifo ahh
|
queue: deque[str] = deque() # fifo ahh
|
||||||
|
|
||||||
|
|
||||||
|
def get_local_ip():
|
||||||
|
s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
|
||||||
|
try:
|
||||||
|
# doesn't even have to be reachable
|
||||||
|
s.connect(("10.255.255.255", 1))
|
||||||
|
IP = s.getsockname()[0]
|
||||||
|
except Exception:
|
||||||
|
IP = "127.0.0.1"
|
||||||
|
finally:
|
||||||
|
s.close()
|
||||||
|
return IP
|
||||||
|
|
||||||
|
|
||||||
def link_extract_from_onetab(line: str) -> str:
|
def link_extract_from_onetab(line: str) -> str:
|
||||||
"link | title"
|
"link | title"
|
||||||
link = line.split("|", 1)[0].strip()
|
link = line.split("|", 1)[0].strip()
|
||||||
@@ -25,7 +41,14 @@ def link_extract_from_onetab(line: str) -> str:
|
|||||||
@app.get("/", response_class=HTMLResponse)
|
@app.get("/", response_class=HTMLResponse)
|
||||||
async def index(request: Request):
|
async def index(request: Request):
|
||||||
"idgaf"
|
"idgaf"
|
||||||
return templates.TemplateResponse(request, "index.html", {"routes": app.routes})
|
# Construct the URL using the local IP
|
||||||
|
port = request.url.port or 2222
|
||||||
|
local_ip = get_local_ip()
|
||||||
|
page_url = f"{request.url.scheme}://{local_ip}:{port}"
|
||||||
|
|
||||||
|
return templates.TemplateResponse(
|
||||||
|
request, "index.html", {"routes": app.routes, "page_url": page_url}
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
@app.get("/q", response_class=HTMLResponse)
|
@app.get("/q", response_class=HTMLResponse)
|
||||||
@@ -102,6 +125,61 @@ async def send_queue(lines: str = Form("")):
|
|||||||
return RedirectResponse(url="/queuein", status_code=303)
|
return RedirectResponse(url="/queuein", status_code=303)
|
||||||
|
|
||||||
|
|
||||||
|
texts: dict[str, str] = {} # name (auto or rewrite): content
|
||||||
|
|
||||||
|
|
||||||
|
@app.get("/pastepad")
|
||||||
|
async def pastepad_ui(request: Request):
|
||||||
|
return templates.TemplateResponse(request, "pastepad.html", {"texts": texts})
|
||||||
|
|
||||||
|
|
||||||
|
def random_str(l: int = 8, s=string.ascii_letters + string.digits):
|
||||||
|
return "".join(choice(s) for _ in range(l))
|
||||||
|
|
||||||
|
|
||||||
|
@app.post("/api/pastepad")
|
||||||
|
async def paste_in(content: str, name: Optional[str] = None):
|
||||||
|
if name in texts:
|
||||||
|
return {"name": name, "content": texts[name]}
|
||||||
|
if name is None:
|
||||||
|
name = random_str()
|
||||||
|
texts[name] = content
|
||||||
|
return {"name": name, "content": texts[name]}
|
||||||
|
|
||||||
|
|
||||||
|
@app.get("/api/pastepad")
|
||||||
|
async def paste_query(name: str):
|
||||||
|
if name in texts:
|
||||||
|
return {"name": name, "content": texts[name]}
|
||||||
|
return {"name": None, "content": None}
|
||||||
|
|
||||||
|
|
||||||
|
@app.get("/api/pastepad/all")
|
||||||
|
async def paste_dump():
|
||||||
|
return list({"name": n, "content": c} for n, c in texts.items())
|
||||||
|
|
||||||
|
|
||||||
|
@app.delete("/api/pastepad")
|
||||||
|
async def paste_delete(name: str):
|
||||||
|
if name in texts:
|
||||||
|
t = texts[name]
|
||||||
|
del texts[name]
|
||||||
|
return {"name": name, "content": t}
|
||||||
|
return {"name": None, "content": None}
|
||||||
|
|
||||||
|
|
||||||
|
@app.put("/api/pastepad")
|
||||||
|
@app.patch("/api/pastepad")
|
||||||
|
async def paste_put(name: str, content: str):
|
||||||
|
if name in texts:
|
||||||
|
t = texts[name]
|
||||||
|
texts[name] = content
|
||||||
|
return {"name": name, "content": t}
|
||||||
|
return {"name": None, "content": None}
|
||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
|
import uvicorn
|
||||||
|
|
||||||
uvicorn.run("uhhhhup:app", host="0.0.0.0", port=2222, reload=True)
|
uvicorn.run("uhhhhup:app", host="0.0.0.0", port=2222, reload=True)
|
||||||
# uvicorn --host "0.0.0.0" --port 2222 --reload uhhhhup:app
|
# uvicorn --host "0.0.0.0" --port 2222 --reload uhhhhup:app
|
||||||
Reference in new issue
Block a user