commit
d838353368
2 changed files with 67 additions and 25 deletions
|
@ -25,4 +25,40 @@ proc htmxPassword*(ctx:Context)=
|
|||
else:
|
||||
val.message = ""
|
||||
val.mark = ""
|
||||
ctx.send htmxPassword(pw, val)
|
||||
ctx.send htmxPassword(pw, val)
|
||||
|
||||
proc htmxFirstName*(ctx:Context)=
|
||||
var
|
||||
fn = ctx.urlForm["fn"]
|
||||
val: Validity
|
||||
if fn == "":
|
||||
val.message = "First Name is Required"
|
||||
val.mark = "is-invalid"
|
||||
else:
|
||||
val.message = ""
|
||||
val.mark = ""
|
||||
ctx.send htmxFirstName(fn,val)
|
||||
|
||||
proc htmxLastName*(ctx:Context)=
|
||||
var
|
||||
ln = ctx.urlForm["ln"]
|
||||
val: Validity
|
||||
if ln == "":
|
||||
val.message = "First Name is Required"
|
||||
val.mark = "is-invalid"
|
||||
else:
|
||||
val.message = ""
|
||||
val.mark = ""
|
||||
ctx.send htmxLastName(ln,val)
|
||||
|
||||
proc htmxPhone*(ctx:Context)=
|
||||
var
|
||||
ph = ctx.urlForm["ph"]
|
||||
val: Validity
|
||||
if ph == "":
|
||||
val.message = "First Name is Required"
|
||||
val.mark = "is-invalid"
|
||||
else:
|
||||
val.message = ""
|
||||
val.mark = ""
|
||||
ctx.send htmxPhone(ph,val)
|
54
src/hh1.nim
54
src/hh1.nim
|
@ -75,6 +75,12 @@ load()
|
|||
|
||||
"/htmx/password" -> post: htmxPassword(ctx)
|
||||
|
||||
"/htmx/fname" -> post: htmxFirstName(ctx)
|
||||
|
||||
"/htmx/lname" -> post: htmxLastName(ctx)
|
||||
|
||||
"/htmx/phone" -> post: htmxPhone(ctx)
|
||||
|
||||
"/:path" -> get:
|
||||
var
|
||||
user1 = ctx.cookies.getOrDefault("user1", "")
|
||||
|
@ -82,31 +88,31 @@ load()
|
|||
compileTemplateFile("view" / "404.html", baseDir = getScriptDir())
|
||||
|
||||
# Experimental
|
||||
"/hi" -> get:
|
||||
var
|
||||
user1 = ctx.cookies.getOrDefault("user1", "")
|
||||
user = getUserFromCookie(user1)
|
||||
uploadcare_pub_key = getEnv("UPLOAD_CARE_PUBLIC_KEY")
|
||||
compileTemplateFile("view" / "hi.html", baseDir = getScriptDir())
|
||||
# "/hi" -> get:
|
||||
# var
|
||||
# user1 = ctx.cookies.getOrDefault("user1", "")
|
||||
# user = getUserFromCookie(user1)
|
||||
# uploadcare_pub_key = getEnv("UPLOAD_CARE_PUBLIC_KEY")
|
||||
# compileTemplateFile("view" / "hi.html", baseDir = getScriptDir())
|
||||
|
||||
"/delete-hi" -> post:
|
||||
var
|
||||
client = newHttpClient()
|
||||
uploadcare_pub_key = getEnv("UPLOAD_CARE_PUBLIC_KEY")
|
||||
uploadcare_secret_key = getEnv("UPLOAD_CARE_SECRET_KEY")
|
||||
client.headers = newHttpHeaders({"Authorization": fmt"Uploadcare.Simple {uploadcare_pub_key}:{uploadcare_secret_key}"})
|
||||
var form = ctx.urlForm
|
||||
echo form
|
||||
var img_uuid = form["img1"]
|
||||
echo img_uuid
|
||||
echo fmt"https://api.uploadcare.com/files/{img_uuid}/storage/"
|
||||
try:
|
||||
let response = client.request(fmt"https://api.uploadcare.com/files/{img_uuid}/storage/", httpMethod = HttpDelete)
|
||||
echo response.status
|
||||
finally:
|
||||
client.close()
|
||||
var js = parseJson("""{"status": "success"}""")
|
||||
ctx.send(js)
|
||||
# "/delete-hi" -> post:
|
||||
# var
|
||||
# client = newHttpClient()
|
||||
# uploadcare_pub_key = getEnv("UPLOAD_CARE_PUBLIC_KEY")
|
||||
# uploadcare_secret_key = getEnv("UPLOAD_CARE_SECRET_KEY")
|
||||
# client.headers = newHttpHeaders({"Authorization": fmt"Uploadcare.Simple {uploadcare_pub_key}:{uploadcare_secret_key}"})
|
||||
# var form = ctx.urlForm
|
||||
# echo form
|
||||
# var img_uuid = form["img1"]
|
||||
# echo img_uuid
|
||||
# echo fmt"https://api.uploadcare.com/files/{img_uuid}/storage/"
|
||||
# try:
|
||||
# let response = client.request(fmt"https://api.uploadcare.com/files/{img_uuid}/storage/", httpMethod = HttpDelete)
|
||||
# echo response.status
|
||||
# finally:
|
||||
# client.close()
|
||||
# var js = parseJson("""{"status": "success"}""")
|
||||
# ctx.send(js)
|
||||
|
||||
servePublic("src/public", "/static")
|
||||
|
||||
|
|
Loading…
Reference in a new issue