欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页

The POST and GET of Mochiweb

程序员文章站 2022-07-15 22:20:20
...

 

%% The request  of POST
113     Form = mochiweb_request:parse_post(Req),    

 

%%  The request of GET

113     Form = mochiweb_request:parse_qs(Req),    

 

%% The file  upload

 79     Form = mochiweb_multipart:parse_form(Req),

 80     ?DEBUG("~p:~p sss length(Form)=~p", [?MODULE, ?LINE, length(Form)]),

 81     Jid = proplists:get_value("jid", Form, ""),

 

 

%% download file

218 parse_request_get(Req, "file/get_small_avatar/"++Path, DocRoot) ->

219     NewPath="avatar/small/"++Path++".jpg",

220     Req:serve_file(NewPath, DocRoot);

 

 

113     Form = mochiweb_request:parse_post(Req),                                                                                          

114     ?DEBUG("~p:~p sss Form=~p", [?MODULE, ?LINE, Form]),

115     Username = proplists:get_value("username", Form, ""),

116     Password = proplists:get_value("password", Form, ""),

117     Type = proplists:get_value("type", Form, ""),

 

184             Req:ok({"text/html", [], <<"<html>

185                 <head><meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\" />

186                 </head><body><h1>APK上传</h1>

187                 <form enctype=\"multipart/form-data\" action=\"/upload/save_apk\" method=\"post\">

188                 <label for=\"file\">版本号</label>

189                 <input type=\"input\" name=\"version\" id=\"version\"/>

190                 <label for=\"file\">描述</label>

191                 <input type=\"input\" name=\"desc\" id=\"desc\"/>

192                 <label for=\"file\">server</label>

193                 <input type=\"input\" value='wx.com' name=\"server\" id=\"version\"/>

194                 <input type=\"file\" name=\"file\" id=\"file\"/>

195                 <input type=\"submit\" name=\"upload\" value=\"Upload\" />

196                 </form>

197                 </body></html>">>});