异步加载css文件

基于python的最简单jQuery File Upload示例

妙音 posted @ 2015年3月27日 13:42 in webui with tags python flask jquery , 11767 阅读
找到个很不错的文件上传插件jQuery File Upload. 资料太少. 只能自己搭个环境,照着例子摸索. 奈何最简单的例子是基于php的, 不熟. 弄了个基于python的例子.
  • github
https://github.com/blueimp/jQuery-File-Upload
  • 目录
使用flask做了个简单web服务器,接收上传请求. 目录结构如下
https://github.c➜  flask-demo  tree
.
├── app.py
├── static
│   ├── 123.txt
│   └── file-upload
│       ├── angularjs.html
│       ├── basic.html
│       ├── basic-plus.html
│       ├── blueimp-file-upload.jquery.json
│       ├── bower.json
│       ├── CONTRIBUTING.md
│       ├── cors
│       │   ├── postmessage.html
│       │   └── result.html
│       ├── css
│       │   ├── demo.css
│       │   ├── demo-ie8.css
│       │   ├── jquery.fileupload.css
│       │   ├── jquery.fileupload-noscript.css
│       │   ├── jquery.fileupload-ui.css
│       │   ├── jquery.fileupload-ui-noscript.css
│       │   └── style.css
│       ├── Gruntfile.js
│       ├── img
│       │   ├── loading.gif
│       │   └── progressbar.gif
│       ├── index.html
│       ├── jquery-ui.html
│       ├── js
│       │   ├── app.js
│       │   ├── cors
│       │   │   ├── jquery.postmessage-transport.js
│       │   │   └── jquery.xdr-transport.js
│       │   ├── jquery.fileupload-angular.js
│       │   ├── jquery.fileupload-audio.js
│       │   ├── jquery.fileupload-image.js
│       │   ├── jquery.fileupload-jquery-ui.js
│       │   ├── jquery.fileupload.js
│       │   ├── jquery.fileupload-process.js
│       │   ├── jquery.fileupload-ui.js
│       │   ├── jquery.fileupload-validate.js
│       │   ├── jquery.fileupload-video.js
│       │   ├── jquery.iframe-transport.js
│       │   ├── jquery.min.js
│       │   ├── main.js
│       │   └── vendor
│       │       └── jquery.ui.widget.js
│       ├── package.json
│       ├── README.md
│       ├── server
│       │   ├── gae-go
│       │   │   ├── app
│       │   │   │   └── main.go
│       │   │   ├── app.yaml
│       │   │   └── static
│       │   │       ├── favicon.ico
│       │   │       └── robots.txt
│       │   ├── gae-python
│       │   │   ├── app.yaml
│       │   │   ├── main.py
│       │   │   └── static
│       │   │       ├── favicon.ico
│       │   │       └── robots.txt
│       │   ├── node
│       │   │   ├── package.json
│       │   │   ├── public
│       │   │   │   └── files
│       │   │   │       └── thumbnail
│       │   │   ├── server.js
│       │   │   └── tmp
│       │   └── php
│       │       ├── files
│       │       ├── index.php
│       │       └── UploadHandler.php
│       ├── test
│       │   ├── index.html
│       │   └── test.js
│       └── test.html
└── templates
    └── index.html

23 directories, 57 filesom/blueimp/jQuery-File-Upload
  • app.py
#encoding=utf-8
from flask import Flask
from flask import request
from flask import abort, redirect, url_for
from flask import render_template
import json

app = Flask(__name__)


@app.route('/')
def index():
    return render_template('index.html')


@app.route('/upload', methods=['GET', 'POST'])
def upload_file():
    if request.method == 'POST':
        f = request.files['files[]']
        filename = f.filename
        minetype = f.content_type
        f.save('static/' + filename)
    return json.dumps({"files": [{"name": filename, "minetype": minetype}]})


if __name__ == '__main__':
    app.run(host="0.0.0.0", port=7000, debug=True)
  • demo.html
<!DOCTYPE HTML>
<html>
<head>
<meta charset="utf-8">
<title>jQuery File Upload 示例</title>
</head>
<body>
<input id="fileupload" type="file" name="files[]" data-url="/upload" multiple>
<script src="/static/file-upload/js/jquery.min.js"></script>
<script src="/static/file-upload/js/vendor/jquery.ui.widget.js"></script>
<script src="/static/file-upload/js/jquery.iframe-transport.js"></script>
<script src="/static/file-upload/js/jquery.fileupload.js"></script>
<script>
$(function () {
    $('#fileupload').fileupload({
        dataType: 'json',
        done: function (e, data) {
            $.each(data.result.files, function (index, file) {
                $('<p/>').text(file.name).appendTo(document.body);
            });
        }
    });
});
</script>
</body> 
</html>
试了之后,确实很不错.
 
Avatar_small
Buy a 314 Area code 说:
2018年7月19日 15:22

Buy a 314 Area code Phone Numbers

Avatar_small
SaaS Security Postur 说:
2020年12月14日 15:22

including reasonable comments here...

Avatar_small
ali 说:
2021年1月20日 21:41

I read this article. I think You put a great deal of exertion to make this article. I like your work. 토토사이트

Avatar_small
casino courchevel 说:
2021年1月21日 22:54

You will find on these online casinos a wide range of games of all kinds, provided you choose a reliable casino that allows you to have opportunities to collect winnings, what to combine the useful with the pleasant.

Avatar_small
ali 说:
2021年1月24日 20:26

I read this article. I think You put a lot of effort to create this article. I appreciate your work. น้ำยาpod

Avatar_small
cross border ecommer 说:
2021年1月28日 23:46

<a href="http://www.cnlogistics.com.hk/tc/Contact.aspx">http://www.cnlogistics.com.hk/tc/Contact.aspx</a> CN Logistics is a well-established international logistics solutions provider. Supported by our 13 global offices, together with a network of international freight forwarding partners and agents, our Group is able to provide its services to locations worldwide.

Avatar_small
ali 说:
2021年2月08日 19:32

This is very significant, and yet necessary towards just click this unique backlink: 그래프게임

Avatar_small
Andrea Natale 说:
2021年2月28日 18:40

This blog is so nice to me. I will keep on coming here again and again. Visit my link as well..

Avatar_small
الكترو صيانة 说:
2021年3月03日 02:44

A company specializing in the maintenance of home appliances in Riyadh and Jeddah

Avatar_small
صيانة ثلاجات بالخبر 说:
2021年3月03日 03:25

The best company specializing in the maintenance of various home appliances, and we also have the best technical team at the highest level of experience and efficiency

Avatar_small
صيانة ثلاجات بمكة 说:
2021年3月03日 03:26

The best company specializing in the maintenance of various home appliances, and we also have the best technical team at the highest level of experience and efficiency

Avatar_small
صيانة ثلاجات بالدمام 说:
2021年3月03日 03:27

The best company specializing in the maintenance of various home appliances, and we also have the best technical team at the highest level of experience and efficiency

Avatar_small
صيانة ثلاجات بجدة 说:
2021年3月03日 03:28

The best company specializing in the maintenance of various home appliances, and we also have the best technical team at the highest level of experience and efficiency

Avatar_small
شركة تصليح ثلاجات 说:
2021年3月03日 03:31

The best company specializing in the maintenance of various home appliances, and we also have the best technical team at the highest level of experience and efficiency

Avatar_small
صيانة افران بالدمام 说:
2021年3月03日 03:41

The best company specializing in the maintenance of various home appliances, and we also have the best technical team at the highest level of experience and efficiency

Avatar_small
تنظيف افران بالرياض 说:
2021年3月03日 03:42

The best company specializing in the maintenance of various home appliances, and we also have the best technical team at the highest level of experience and efficiency

Avatar_small
تنظيف افران بالدمام 说:
2021年3月03日 03:43

The best company specializing in the maintenance of various home appliances, and we also have the best technical team at the highest level of experience and efficiency

Avatar_small
صيانة مجفف حراري بجد 说:
2021年3月03日 03:45

The best company specializing in the maintenance of various home appliances, and we also have the best technical team at the highest level of experience and efficiency

Avatar_small
Journal seo blog 说:
2021年4月01日 18:00

The best company specializing in the maintenance of various home appliances, and we also have the best technical team at the highest level of experience and efficiency

Avatar_small
123 movies 说:
2021年4月02日 23:06

Nice post. I was checking constantly this blog and I am impressed! Extremely helpful information specially the last part

Avatar_small
idn poker 说:
2021年4月03日 05:35

I've proper selected to build a blog, which I hold been deficient to do for a during. Acknowledges for this inform, it's really serviceable!

Avatar_small
Multilingual Link Bu 说:
2021年4月04日 00:18

I am very enjoyed for this blog. Its an informative topic. It help me very much to solve some problems. Its opportunity are so fantastic and working style so speedy.

Avatar_small
buiding work prices 说:
2021年4月05日 23:17

We are really grateful for your blog post. You will find a lot of approaches after visiting your post. I was exactly searching for. Thanks for such post and please keep it up. Great work

Avatar_small
pawn shops in avonda 说:
2021年4月07日 06:09

It is imperative that we read blog post very carefully. I am already done it and find that this post is really amazing.

Avatar_small
keto allergies 说:
2021年4月10日 12:18

Thanks for sharing this quality information with us. I really enjoyed reading. Will surely going to share this URL with my friends.

Avatar_small
become a merchant ac 说:
2021年6月14日 14:28

This blog is so nice to me. I will keep on coming here again and again. Visit my link as well..

Avatar_small
credit card processi 说:
2021年6月16日 13:02

I read a article under the same title some time ago, but this articles quality is much, much better. How you do this..

Avatar_small
TopNeeds 说:
2021年6月22日 16:32

I read this article. I think You put a lot of effort to create this article. I appreciate your work

Avatar_small
viagra cialis 说:
2021年6月28日 00:36

I really appreciate this wonderful post that you have provided for us. I assure this would be beneficial for most of the people.

Avatar_small
gilbert realtors 说:
2021年6月29日 01:09

Fabulous blog post, you have actually signified out some amazing factors, I furthermore believe this s a really remarkable website. I will certainly visit once more for even more quality material and additionally, suggest this website to all. Thanks.

Avatar_small
더킹카지노 说:
2021年7月02日 05:57

I read this article. I think You put a great deal of exertion to make this article. I like your work.

Avatar_small
온라인홀덤 说:
2021年7月11日 00:39

wow i can say that this is another great article as expected of this blog.bookmarked this site.

Avatar_small
Satta king 说:
2021年9月25日 01:57

I should assert barely that its astounding! The blog is informational also always fabricate amazing entitys.

Avatar_small
quinceanera planner 说:
2021年12月10日 01:37

When it comes to planning events, we are here to provide professional, personalized, detailed, and unique concierge services for you and your guests.
<a href="https://eventsofpittsburgh.com/">https://eventsofpittsburgh.com/</a>

Avatar_small
johnyking 说:
2021年12月30日 18:43

I found that site very usefull and this survey is very cirious, I ' ve never seen a blog that demand a survey for this actions, very curious... 토토사이트

Avatar_small
satta matta matka 说:
2021年12月30日 19:31

Great post, please keep on sharing amazing article like this! It makes me happy reading your post

Avatar_small
รีวิวเว็บufabet 说:
2022年1月22日 20:56

Nice post. I was checking constantly this blog and I am impressed! Extremely helpful information specially the last part

Avatar_small
hair care products 说:
2022年2月01日 20:37

Wisdom Pharma offers you all the best selfcare products in one convenient place, such as their. So, buy from Wisdom Pharma and get high quality hair care online. Wisdom Pharma brings the best hair care products in Pakistan. Get healthier, fuller hair today.

Avatar_small
best serums for glow 说:
2022年2月02日 19:58

Wisdom Pharma offers you all the best selfcare products in one convenient place, such as their skin glow creams. So, buy from Wisdom Pharma and get the best serums for glowing skin online. Wisdom Pharma brings the best serums for glowing skin in Pakistan.

Avatar_small
johnyking 说:
2022年3月29日 14:03

I definitely enjoying every little bit of it. It is a great website and nice share. I want to thank you. Good job! You guys do a great blog, and have some great contents. Keep up the good work. Bottled and Jarred Packaged Goods

Avatar_small
johnyking 说:
2022年4月05日 03:33

I think this is an informative post and it is very useful and knowledgeable. therefore, I would like to thank you for the efforts you have made in writing this article. <a href="https://sigmaproperties.com.pk/capital-smart-city-islamabad/">Capital Smart City</a>

Avatar_small
jackseo 说:
2022年4月07日 01:26

Thank you again for all the knowledge you distribute,Good post. I was very interested in the article, it's quite inspiring I should admit. I like visiting you site since I always come across interesting articles like this one.Great Job, I greatly appreciate that.Do Keep sharing! Regards, theme in literature

Avatar_small
jackseo 说:
2022年4月07日 19:37

Wow, What an Outstanding post. I found this too much informatics. It is what I was seeking for. I would like to recommend you that please keep sharing such type of info.If possible, Thanks. detectives en málaga

Avatar_small
jackseo 说:
2022年4月08日 18:56

Thanks for sharing this valuable content. In my view, if all webmasters and bloggers made good content as you did, the web will be a lot more useful than ever before. golden revive plus reviews

Avatar_small
jackseo 说:
2022年4月11日 04:57

Please let me know if you’re looking for a article writer for your site. You have some really great posts and I feel I would be a good asset. If you ever want to take some of the load off, I’d absolutely love to write some material for your blog in exchange for a link back to mine. Please send me an email if interested. Thank you! kingdom valley islamabad payment plan

Avatar_small
jackseo 说:
2022年4月13日 04:19

Succeed! It could be one of the most useful blogs we have ever come across on the subject. Excellent info! I’m also an expert in this topic so I can understand your effort very well. Thanks for the huge help. kingdom valley islamabad office

Avatar_small
jackseo 说:
2022年4月14日 18:26

Thank you for such a well written article. It’s full of insightful information and entertaining descriptions. Your point of view is the best among many. Lahore smart city

Avatar_small
jackseo 说:
2022年4月17日 04:04

What a fantabulous post this has been. Never seen this kind of useful post. I am grateful to you and expect more number of posts like these. Thank you very much. สมัครสล็อต

Avatar_small
jackseo 说:
2022年4月20日 04:34

I love the way you write and share your niche! Very interesting and different! Keep it coming! https://www.tetongravity.com/community/profile/megablue/

Avatar_small
ssali 说:
2022年5月22日 19:05

Amazing, this really solved my problem. i am going to bookmark it, if you are looking for lyca beltegoed, lebara beltegoed, lyca bundel xs, samsung a52, samsung a51, samsung a72, iphone 13 pro max in Netherlands, get in touch with us.

 


登录 *


loading captcha image...
(输入验证码)
or Ctrl+Enter