using Oxygen using HTTP using DBInterface, MySQL conn = DBInterface.connect(MySQL.Connection, "xigmanas", "itman", "X753951x", db="sea") staticfiles("./dist", "/") # staticfiles("./dist/font", "/font") # Определение маршрута для обработки запросов и возврата файла index.html @get "/" function(req::HTTP.Request) return html(read("./dist/index.html", String), status=200) end @get "/album/{album}" function(req::HTTP.Request, album::String) # println("get album: $(album)") cmd = """ select filemeta.id, newurl, thumb.url as srct, thumb.width as widtht, thumb.height as heightt from filemeta join pic on filemeta.id = pic.file_id join thumb on filemeta.id = thumb.file_id where pic.seria = '$album' and filemeta.del = 0 limit 100 """ rows = DBInterface.execute(conn, cmd) answer = [] for r in rows push!(answer, Dict( "id"=>r.id, "newurl"=>r.newurl, "srct"=>r.srct, "widtht"=>r.widtht, "heightt"=>r.heightt )) end # println("$album: $(length(answer))") json(answer) end @get "/albums" function(req::HTTP.Request) # println("get album: $(album)") cmd = """ select pic.seria, count(pic.seria) as cnt from pic join filemeta on pic.file_id = filemeta.id where filemeta.del = 0 and pic.seria not like "comic%" group by pic.seria -- limit 10 """ rows = DBInterface.execute(conn, cmd) answer = [] for r in rows push!(answer, Dict( "album"=>r.seria, "count"=>r.cnt )) end json(answer) end title = "nano4 v1.0.0 (30-01-2024)" printstyled("[ Стартую сервер: $(title)\n", color = :magenta, bold = true) # set application level middleware serve(port=4321)