update of rikiki

This commit is contained in:
Mindiell 2023-09-17 15:34:44 +02:00
parent deb0362407
commit efccb57083
2 changed files with 15 additions and 2 deletions

View File

@ -16,7 +16,8 @@ To run this wiki, you need python3 only :
1. Create a folder named "wiki"
2. Create a sub-folder named "cgi-bin"
3. Copy rikiki.py inside the "cgi-bin" folder
4. Run this command from the wiki folder :
4. chmod +x on rikiki.py
5. Run this command from the wiki folder :
PYTHONWARNINGS="ignore" python -m http.server --cgi
Now, you can go and visit : http://localhost:8000/cgi-bin/rikiki.py?p=HomePage

View File

@ -1,2 +1,14 @@
#!/usr/bin/env python3
import cgi,json as j,re as r;p,s,c=map(cgi.parse().get,"psc");p,o=p[0],open;s and o(p,"w").write(s[0]);o(p,"a");o("b","a");l,k,v=j.loads(o("b").read()or"{}"),r"(([A-Z][\w]+){2})",r"<a href=?p=\1>\1</a>";c=s[0] if s else o(p).read();l[p]=[x[0] for x in r.findall(k,c)];h=r.sub(k,v,c,r.M);h=r.sub(r"\n","<p>",h,r.M);j.dump(l,o("b","w"));print('Content-Type: text/html\n\n%s<form method=POST><textarea name=s>%s</textarea><input type=submit></form>'%(h,c));[n==p and print(r.sub(k,v,m)) for m in l for n in l[m]]
import cgi,json as j,re as r
p,s,c=map(cgi.parse().get,"psc")
p,o=p[0],open
s and o(p,"w").write(s[0])
o(p,"a");o("b","a")
l,k,v=j.loads(o("b").read()or"{}"),r"(([A-Z][\w]+){2})",r"<a href=?p=\1>\1</a>"
c=s[0] if s else o(p).read()
l[p]=[x[0] for x in r.findall(k,c)]
h=r.sub(k,v,c,r.M)
h=r.sub(r"\n","<p>",h,r.M)
j.dump(l,o("b","w"))
print('Content-Type: text/html\n\n%s<form method=POST><textarea name=s>%s</textarea><input type=submit></form>'%(h,c))
[n==p and print(r.sub(k,v,m)) for m in l for n in l[m]]