33
|
1 local Luan = require "luan:Luan.luan"
|
|
2 local error = Luan.error
|
|
3 local stringify = Luan.stringify or error()
|
|
4 local Io = require "luan:Io.luan"
|
|
5 local Http = require "luan:http/Http.luan"
|
|
6 local Shared = require "site:/lib/Shared.luan"
|
|
7 local get_url_from_file = Shared.get_url_from_file or error()
|
|
8 local Logging = require "luan:logging/Logging.luan"
|
|
9 local logger = Logging.logger "test/upload.js"
|
|
10
|
|
11
|
|
12 return function()
|
|
13 local file = Http.request.parameters.file or error()
|
|
14 --logger.info(stringify(file));
|
|
15 local url = get_url_from_file(file)
|
|
16 --logger.info("url = "..url)
|
|
17 Io.stdout = Http.response.text_writer()
|
|
18 %>
|
|
19 let url = '<%=url%>';
|
|
20 let a = document.querySelector('a');
|
|
21 a.textContent = url;
|
|
22 a.setAttribute('href',url);
|
|
23 <%
|
|
24 end
|