异步加载css文件

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

妙音 posted @ 2015年3月27日 13:42 in webui with tags python flask jquery , 12219 阅读
找到个很不错的文件上传插件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.

 

Avatar_small
bangalitantrik 说:
2022年6月25日 17:22

This post is good enough to make somebody understand this amazing thing, and I’m sure everyone will appreciate this interesting things.

Avatar_small
lovemaulana 说:
2022年6月25日 18:32

This is really a high quality content. Very helpful & informative.

Avatar_small
lovevashiastro 说:
2022年6月25日 18:51

Wish you a good luck with best wishes. Your web page is excellent, carry on your good job.

Avatar_small
muslimblackmagic 说:
2022年6月25日 19:11

Good way of presenting this article. Magnificent site, got lots of useful information here.

Avatar_small
dainikastro 说:
2022年6月25日 20:07

I welcome you to the page where you can limit with stunning data on faint subjects.

Avatar_small
dainikastrology 说:
2022年6月25日 20:55

Wish you a good luck with best wishes. Your web page is excellent, carry on your good job.

Avatar_small
Cheapest Car Rental 说:
2022年6月29日 13:55

Good post. I study something more difficult on different blogs everyday. It’s going to always be stimulating to learn content material from other writers and observe a little bit one thing from their store. I’d prefer to use some with the content material on my blog whether you don’t mind. Natually I’ll give you a link in your web blog. Thanks for sharing.

Avatar_small
Rera Registration 说:
2022年6月29日 19:32

This webpage provides useful data to us, keep it up. I had been looking.

Avatar_small
uaecarpet 说:
2022年8月06日 14:51

<a href='https://uaecarpet.com/dubai-carpet-cleaning-services/' title='carpet shop in deira dubai' target='_blank'>carpet shop in deira dubai</a>
<a href='https://uaecarpet.com/carpet-shops-and-stores-in-dubai-and-uae/' title='dubai carpet market' target='_blank'>dubai carpet market</a>

Avatar_small
updatedverse 说:
2022年8月06日 20:20

<a href='https://updatedverse.com/how-much-does-it-cost-to-develop-an-app-on-flutter/' title='cost of developing an app on Flutter' target='_blank'>cost of developing an app on Flutter</a>

<a href='https://updatedverse.com/how-does-an-lms-ease-performance-management-processes/' title='lms performance management' target='_blank'>lms performance management</a>

<a href='https://updatedverse.com/future-scope-of-machine-learning-in-2022/' title='Machine Learning' target='_blank'>Machine Learning</a>

<a href='https://updatedverse.com/what-kind-of-impact-will-artificial-intelligence-have-on-cybersecurity/' title='Impact Will Artificial Intelligence Have On Cybersecurity' target='_blank'>Impact Will Artificial Intelligence Have On Cybersecurity</a>

Avatar_small
dark web/deep web/d 说:
2022年8月09日 15:02

When a web directory sees that you have bid on a particular keyword, it will assign an affiliate link to you. There are web directories that allow you to make money by being listed on as many as 10. dark web links

Avatar_small
dark web/deep web/d 说:
2022年8月09日 15:39

Pay per click advertising and link farms can both be used to generate income online. Each method has its advantages and disadvantages.  deep web

Avatar_small
dark web/deep web/d 说:
2022年8月09日 16:36

The world of the internet has come a long way in the past decade. Sites have become more user friendly and accessible to anyone with an internet connection.  dark web sites

Avatar_small
dark web/deep web/d 说:
2022年8月09日 19:39

The dark web has become a popular place to buy and sell illegal items like drugs and other illicit materials. dark web links

Avatar_small
dark web/deep web/d 说:
2022年8月09日 22:25

If a company does not provide any contact information, it means that they do not really exist. Legitimate credit card companies do not hide their telephone number or email address to anyone.  dark web

Avatar_small
dark web/deep web/d 说:
2022年8月09日 23:00

The truth is that it doesn't matter whether you start your affiliate marketing business without a website. As long as you can take visitors to your website and show them the products that you're selling then you should be able to generate sales without a website.  work from home jobs

Avatar_small
dark web/deep web/d 说:
2022年8月09日 23:35

Another way that you can start to generate traffic to your website is by creating a forum. Forums are very popular because everyone is interested in something.  affiliate marketing success

Avatar_small
how to delete an ins 说:
2022年8月10日 17:01

Completely deleting your Instagram Account will get all your activity connection and activities through this account to be removed permanently, and also Comments, Likes, photos, Videos and your follower will be completely removed from the Instagram Account. how to delete instagram account permanently This process of deleting an Instagram Account is nowhere a recoverable process, thus if you want to get an account removed you may need to think twice and confirm, and make sure you have got the password for the Instagram Account that you want to delete from your MAC or Android, else you won’t be able to proceed further.

Avatar_small
updatedverse 说:
2022年9月07日 19:09

<a href='https://updatedverse.com/digital-marketing/' title='Why Digital Marketing Is A Valuable Tool For Businesses' target='_blank'>Why Digital Marketing Is A Valuable Tool For Businesses</a>
<a href='https://updatedverse.com/do-you-know-the-4-digital-marketing-funnels/' title='Do You Know The 4 Digital Marketing Funnels?' target='_blank'>Do You Know The 4 Digital Marketing Funnels?</a>
<a href='https://updatedverse.com/is-email-marketing-still-relevant-what-types-of-edm-do-you-need/' title='Is Email Marketing Still Relevant? What Types Of EDM Do You Need?' target='_blank'>Is Email Marketing Still Relevant? What Types Of EDM Do You Need?</a>
<a href='https://updatedverse.com/mobile-gaming/' title='Top Mobile Gaming Trends For 2022' target='_blank'>Top Mobile Gaming Trends For 2022</a>
<a href='https://updatedverse.com/virtual-cto/' title='7 Things To Know About Virtual CTO' target='_blank'>7 Things To Know About Virtual CTO</a>
<a href='https://updatedverse.com/mobile-seo/' title='Why Is Mobile SEO Important?' target='_blank'>Why Is Mobile SEO Important?</a>
<a href='https://updatedverse.com/social-media-marketing/' title='Does Social Media Marketing Affect Small Businesses?' target='_blank'>Does Social Media Marketing Affect Small Businesses?</a>
<a href='https://updatedverse.com/customer-service/' title='How To Improve Customer Service For A Successful Business' target='_blank'>How To Improve Customer Service For A Successful Business</a>
<a href='https://updatedverse.com/private-internet-access/' title='All Things One Needs To Understand About Private Internet Access' target='_blank'>All Things One Needs To Understand About Private Internet Access</a>
<a href='https://updatedverse.com/drones/' title='Drones For Traveling: Buying Considerations For Photographers' target='_blank'>Drones For Traveling: Buying Considerations For Photographers</a>
<a href='https://updatedverse.com/cloud-data-management/' title='7 Best Practices For Cloud Data Management' target='_blank'>7 Best Practices For Cloud Data Management</a>
<a href='https://updatedverse.com/best-podcast-app-in-the-ios/' title='How To Find The Best Podcast App In The IOS Device' target='_blank'>How To Find The Best Podcast App In The IOS Device</a>
<a href='https://updatedverse.com/argumentative-essay/' title='How To Write An Argumentative Essay Introduction' target='_blank'>How To Write An Argumentative Essay Introduction</a>

Avatar_small
AP SSC fa 2 Model Pa 说:
2022年9月09日 19:32

Formative Assessment means not only an examination, it includes various aspects such as Examination in completed lessons, Reflections, Project work done on the allotted topic and Self also Prepared notes etc. AP SSC fa 2 Model Paper Candidates of Telugu Medium, English Medium & Urdu Medium of the AP State can download the AP 10th Class FA 4 Model Paper 2023 Pdf with answers for the regular exams conducted by the Directorate of Government Examinations, Andhra Pradesh.

Avatar_small
seo 说:
2022年9月22日 15:12

So it is interesting and very good written and see what they think about other people. Comment acheter Ethereum

Avatar_small
seo 说:
2022年9月27日 19:27

Baccarat online betting website Reviews from real users in play baccarat online Review of deposits and withdrawals and look at the stability of the web to play The process of investing and using good services as a part of using the service. บาคาร่า99

Avatar_small
seo 说:
2022年9月29日 20:26

football betting or online football betting website The camp that Thai people accept isa popular online football betting website with complete services. แทงบอลโลก

Avatar_small
seo 说:
2022年9月30日 15:32

So it is interesting and very good written and see what they think about other people. 파워볼

Avatar_small
seo 说:
2022年10月05日 15:56

Cool you write, the information is very good and interesting, I'll give you a link to my site. แทงบอลโลก

Avatar_small
seo 说:
2022年10月06日 23:14

members regarded as The most popular online gambling website,  UFABET,  the best direct website based on reviews on various social media. and a small number of members Choose to use online gambling services with football betting websites.  and of course the number of members of This เว็บพนันออนไลน์


登录 *


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