first commit
This commit is contained in:
77
www/docs/queries.pyp
Normal file
77
www/docs/queries.pyp
Normal file
@@ -0,0 +1,77 @@
|
||||
<py!>
|
||||
import components.code as code
|
||||
import components.docs as docs
|
||||
</py!>
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title>pyp | queries</title>
|
||||
<script src="https://cdn.tailwindcss.com"></script>
|
||||
</head>
|
||||
<body class="font-sans min-h-[90vh] flex flex-col items-center">
|
||||
<div class="w-full max-w-[80vw] flex gap-5 h-10 bg-slate-900/50 py-5 fixed my-5 p-6 rounded-full backdrop-blur-md lg:max-w-3xl items-center justift-around text-white">
|
||||
<a class="font-bold" href="./">PyWPR docs</a>
|
||||
</div>
|
||||
<div class="inline-flex flex-col gap-5 items-center max-w-[85vw] lg:max-w-3xl mt-20">
|
||||
<h1 class="text-4xl">
|
||||
pyp | queries
|
||||
</h1>
|
||||
<p class="text-center">in pywrp we use <span class="bg-black p-2 rounded-xl text-white font-mono">pyp.GET</span> object for ?get=queries<br>
|
||||
you can access query parameters like dictionary keys<br>
|
||||
for example:</p>
|
||||
<p?>
|
||||
code.code_comp("""pyp.GET['name']
|
||||
# or
|
||||
pyp.GET.get('name', 'default_value')""")
|
||||
</p?>
|
||||
<p>try it out:</p>
|
||||
<div class="flex flex-col gap-3 w-full p-5 border rounded-xl bg-gradient-to-br from-blue-50 to-red-100">
|
||||
<div class="flex gap-1.5 *:w-[12px] *:h-[12px] *:bg-slate-800 mb-3 *:rounded-full *:transition ">
|
||||
<span class="hover:bg-red-600"></span>
|
||||
<span class="hover:bg-yellow-300"></span>
|
||||
<span class="hover:bg-green-500"></span>
|
||||
</div>
|
||||
<span class="font-mono text-left w-full"><form method="get"></span>
|
||||
<form method="get" class="flex flex-col gap-3 items-center justify-center w-full ">
|
||||
<div class="flex items-center justify-center w-full *:max-w-40">
|
||||
<input type="text" name="name" placeholder="name" class="p-2 border rounded-xl bg-black/40 text-white placeholder-white/60 text-center" required>
|
||||
<span class="flex items-center"><input type="number " name="money" placeholder="your money" class="p-2 border rounded-xl w-full text-center bg-black/40 text-white placeholder-white/60">$</span></div>
|
||||
<button type="submit" class="bg-gradient-to-br from-blue-500 to-blue-300 w-full max-w-40 text-white p-2 rounded-xl">submit</button>
|
||||
</form>
|
||||
<span class="font-mono text-right w-full"></form></span>
|
||||
<py!>
|
||||
if 'name' in pyp.GET and pyp.GET['name'].strip() != "":
|
||||
name = pyp.GET['name']
|
||||
money = pyp.GET.get('money', "")
|
||||
if money != "" and not money.isdigit():
|
||||
money = ""
|
||||
moneyText = f"you have a {'big' if int(money) >= 100 else "little"} money: <span class=\"font-mono\">{money}$</span>!" if money != "" else "you didn't tell me about your money"
|
||||
e(f"<span class=\"w-full bg-zinc-300 h-0.5\"></span><span class=\"font-mono text-left w-full\"><!py></span><div class=\"w-full text-center\">hello, <span class=\"font-mono\">{name}</span>! {moneyText}</div><span class=\"font-mono text-right w-full\"></py!></span>")
|
||||
</py!>
|
||||
</div>
|
||||
|
||||
<p>source</p>
|
||||
<p?>
|
||||
code.code_comp(f"""<form action="get">
|
||||
<input type="text" name="name" placeholder="name">
|
||||
<input type="number" name="money" placeholder="your money">
|
||||
<button type="submit">submit</button>
|
||||
</form>
|
||||
{'<'}py!>
|
||||
if 'name' in pyp.GET and pyp.GET['name'].strip() != "":
|
||||
name = pyp.GET['name']
|
||||
money = pyp.GET.get('money', '')
|
||||
if money != "" and not money.isdigit():
|
||||
money = ""
|
||||
moneyText = f"you have a {'{'}'big' if int(money) >= 100
|
||||
else "little"{'}'} money: {'{'}money{'}'}$!" \\
|
||||
if money != "" else "you didn't tell me about your money"
|
||||
e(f"<div>hello, {'{'}name{'}'}! {'{'}moneyText{'}'}</div>")
|
||||
</py!>""",'html')
|
||||
</p?>
|
||||
</div>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
Reference in New Issue
Block a user