首页 文章 精选 留言 我的

精选列表

搜索[云开发静态网站托管],共10000篇文章
优秀的个人博客,低调大师

基于Flask开发网站 -- 前端Ajax异步上传文件到后台

大家好,我是辰哥~ 辰哥最近利用空闲时间在写一个在线可视化平台,过程中也觉得一些技术还是比较有意思的,所以就以模块化的形式分享出来。如:从网页界面(前端)上传文件到服务器(后端)。 放一下该模块的界面图瞧一瞧: 点击上传excel文件按钮,选择excel文件后可以在线预览,并且后端接收保存到服务器,本文主要是分享上传文件这块内容。 背景:前端是html,后端使用Flask框架,在前端点击上传一个excel文件,后端接收并保存到本地。 01 前端处理 1.文件选择框 相信写过html代码的都知道,上传文件控件最简单的是html默认的(非使用插件的情况) <input id="file" name="loadfile" type="file"> 文件选择框的id是file,类型是file,通过id去调用js异步代码,类型是指定input是选择本地文件。 这样就定义好一个文件选择框。 2.Ajax异步处理 在使用Ajax异步之前,需要引入Jquery文件 <script src="https://ajax.aspnetcdn.com/ajax/jquery/jquery-3.5.1.min.js"></script> 异步代码: $('#file').change(function (e) { var files = e.target.files; var formFile = new FormData(); formFile.append("file", files[0]); //加入文件对象 $.ajax({ url: "/upload_file", data: formFile, type: "post", dataType: "json", cache: false,//上传文件无需缓存 processData: false,//用于对data参数进行序列化处理 这里必须false contentType: false, //必须 success: function (result) { alert("上传完成!"); }, }) }); 点击网页的上传excel文件按钮,选择好excel文件之后,自动触发上述的js代码(通过id:file去触发指定js代码) > 简单介绍: > > (1)e.target.files:选择上传的文件 > > (2)FormData:将上传文件封装到FormData中 > > (3)/upload_file:后端上传的接口(接收文件的入口) 这段js代码的作用就是将选择好的excel文件,上传到后端接口:/upload_file,后端处理完毕之后返回响应值:result,网页提示:上传完成。 02 后端处理 后端使用Python去编写,用的是Flask框架,如果还不明白的flask的简单使用的,可以参考辰哥之前的一篇文章:Flask结合ECharts实现在线可视化效果,超级详细! 这里辰哥直接带大家看后端接口,详细的完整源码,辰哥会在文末直接给出。 # 上传文件 @app.route('/upload_file', methods=['POST']) def upload(): if request.method == 'POST': f = request.files['file'] basepath = os.path.dirname(__file__) # 当前文件所在路径 print(f.filename) ####################################### # 毫秒级时间戳 file_name = str(round(time.time() * 1000)) dir = str(time.strftime('%y%m%d', time.localtime())) upload_path = os.path.join(basepath, 'uploads/'+dir) # 判断文件夹是否存在 if not os.path.exists(upload_path): os.mkdir(upload_path) ####################################### file_path = str(file_name)+str(f.filename) f.save(upload_path+"/"+file_path) return Response(json.dumps(file_path), mimetype='application/json') 简单说明: (1)接口名称是:/upload_file,接受的请求方式是:post; (2)request.files['file']:接收上传的文件; (3)6~16行:在upload文件夹下自动创建以当天日期命名的文件夹,作为保存上传文件的存储路径; (4)file_name:是当前毫秒级时间戳,对上传的文件重命名:时间戳+原文件名; (5)Response返回文件路径到前端异步处理函数success:file_path; 03 效果 前端和后端都处理完毕后,开始调试程序。看看具体效果。 以上就是前端Ajax异步上传文件到后端的内容。 > 完整的源码地址: > > https://wwi.lanzoui.com/imM6bs2f44d 最后说一声:原创不易,求给个赞!

优秀的个人博客,低调大师

对开发者有用的英文网站合集,建议收藏!

​​问答社区 Stack Overflow: subscribe to their weekly newsletter and any other topic which you find interesting Quora: A place to share knowledge and better understand the world Learn Anything: Community curated knowledge graph of best paths for learning anything devRant: Community where you can rant and release your stress Codementor: A mentorship community to learn from fellow developers via live 1:1 help and more. 新闻 Hacker News: news aggregator for programmers where civility is king, try a newsletter to get top news to your inbox: Hacker Newsletter: curated by hand, delivered weekly Hacker News Digest: curated automatically, delivered as frequently as you want Ars Technica: posts unique quality articles ACM TechNews Lobsters: Lobsters is a technology-focused community centered around link aggregation and discussion. TechCrunch: another good website for tech news GSMArena.com: news related to latest mobile phones and android. product hunt: Discover your next favorite thing AlternativeTo: Crowdsourced software recommendations Better Dev Links: Weekly links to help you become a better developer 初学者的编程练习 freeCodeCamp: Learn to code and build projects for nonprofits. Build your full stack web development portfolio today Reddit.com/r/dailyprogrammer: interesting programming challenges where you can learn from looking at other's code , even if you are not able to solve code you can look at how others solved. Programming by Doing: very good site for those who want to start with absolute basics CodeAbbey - a place where everyone can master programming: Best place to begin with problems that start at the easiest and gradually increase difficulty with each problem. Exercism.io: download and solve practice problems in over 30 different languages, and share your solution with others. Programming Tasks: large collection of small programs karan/Projects-SolutionsSolutions to most of the problems in the link above Lod - Cloud: The Linking Open Data cloud diagram Cave of programming: Learn to program, Upgrade your skills. Codeacademy: Learn to code interactively, for free. 找找项目灵感 martyr2s-mega-project-ideas-list: contains about 125 project ideas from beginner to intermediate level. karan/Projects: a large collection of small projects for beginners with Wrong "big projects" for beginners: How to choose where to start vicky002/1000-Projects: Mega List of practical projects that one can solve in any programming language! 大牛的建议 Things I Wish Someone Had Told Me When I Was Learning How to Code — Free Code Camp: What I’ve learned from teaching others Lessons From A Lifetime Of Being A Programmer: The Codist Header Lessons From A Lifetime Of Being A Programmer Principles of Good Programming: The Principles of Good Programming What every computer science major should know: The Principles of Good Programming How to become a programmer, or the art of Googling well Code Review Best Practices: Kevin London's blog Dieter Rams : 10 Principles of Good Product Design 10-ways-to-be-a-better-developer Working as a Software Developer Software design pattern: The entire collection of Design Patterns. Design Patterns: Design Patterns explained in detail with examples. 编码规范 CS 106B Coding Style Guide: must see for those who create spaghetti Google C++ Style Guide Airbnb JS Style Guide: A mostly reasonable approach to JavaScript Airbnb Ruby Style Guide: A ruby style guide by Airbnb What are some bad coding habits you would recommend a beginner avoid getting into? Good C programming habits. • /r/C_Programming How to Report Bugs Effectively Debugging Faqs Stuff you need to Code Better! Directory of Online CS Courses Directory of CS Courses (many with online lectures) Angular 1 Style Guide: Officially endorsed style guide by John Pappa 通用工具 regex101: Online regex tester and debugger: PHP, PCRE, Python, Golang and JavaScript CodePen: Front End Developer Playground & Code Editor in the Browser 面试准备 Pramp | A free on demand interview practice platform for Software Engineers: Practice coding interviews with real peers GeeksforGeeks | A computer science portal for geeks: also subscribe to their feeds to get links to their new articles. A site for technical interview questions, brain teasers, puzzles, quizzles: whatever the heck those are) and other things that make you think! Problems | LeetCode OJ: Coding practice for interviews Programmer And Software Interview Questions Answers Reddit.com/user/ashish2199/m/puzzles: Logic Puzzles A Collection of Quant Riddles With Answers Aptitude Questions and Answers: Quant and aptitude preparation Interview Archives - Java Honk Top 10 Algorithms for Coding Interview Algorithm design canvas) Big-O Algorithm Complexity Cheat Sheet Unix / Linux Cheat Sheet How to interview How to Ace an Algorithms Interview Delightful Puzzles visualising data structures and algorithms through animation Here's How to Prepare for Tech Interviews • /r/cscareerquestions Guide to Tech Interviews Why You Make Less Money • /r/cscareerquestions IIT Delhi Placement Experience what_are_your_goto_questions_for_the_do_you_have? /r/cscareerquestions: Here's a pretty big list of programming interview questions I compiled while studying for big 4 interviews. I think you guys will find it useful! • Interviewing At Jane Street How to prepare for an interview - 1 Summer Internship: The Ultimate Guide The 25 most difficult HR questions Job interviews News, Videos, Reviews and Gossip - Lifehacker How to Answer the Toughest 40 Job Interview Questions | ICS Job Portal Job Interview Questions and Best Answers How to Answer "Tell Me a Little About Yourself" | The Art of Manliness Job Interview: How to Ace a Job Interview | The Art of Manliness Give your résumé a face lift BIG O Misconceptions Bitwise tricks Core Java Interview questions - Interview question on each topic Java Interview Questions and Answers Big collection of interview preparation links • /r/cscareerquestions Unsolicited_advice_for_job_seekers_and_employers five-essential-phone-screen-questions - steveyegge2 CS9: Problem-Solving for the CS Technical Interview Mission-peace/interview problems: A large collection of coding interview problems SQL Joins explained using venn diagram 10 Frequently asked SQL Query Interview Questions Get Ready to Learn SQL: 8. Database Normalization Explained in Simple English - Essential SQL Programming Language Concepts: Lecture Notes: OOPs concepts and programming language concepts. We Help Coders Get Hired: website offering courses on system design, interview strategies, soft skills etc checkcheckzz/system-design-interview How to Break Into the Tech Industry - a Guide to Job Hunting and Tech Interviews Freshers Interviews C PUZZLES, Some interesting C problems wu :: riddles(hard): logic puzzles and riddles github.com/odino/interviews: list of important questions for interview svozniuk/java-interviews: Java interview questions kimberli/interviews: study sheet for Interview Determining the big-O runtimes of these different loops?: really good stackoverflow question that covers basics of calculating runtime complexity. ChiperSoft/InterviewThis: questions to ask during on a interview to know more about the company. SQL interview questions: great SQL test 视频 Machine that Changed the World - a very good documentary about history of computers Part 1: Giant Brains Part 2: Inventing the Future Part 3: The Paperback Computer Part 4: The Thinking Machine Part 5: The World at Your Fingertips Triumph of the Nerds: Play-list Project Code Rush - The Beginnings of Netscape / Mozilla Documentary The Code: Story of Linux documentary Breaking the Code: Biography of Alan Turing Mechanical Computer (All Parts): a very good video from 1950s explaining how mechanical computers used to work without all the modern day electronics. Download: The True Story of the Internet: Play-list of discovery channel documentary on browser wars , dot com bubble and more. Teach Yourself Computer Science How does CPU execute program (video) Machine Code Instructions (video) Harvard CS50 - Asymptotic Notation (video) Cracking The Code Interview Cracking the Coding Interview - Fullstack Speaker Series Ask Me Anything: Gayle Laakmann McDowell (author of Cracking the Coding Interview) MOOCs Class Central: a directory of 100,000+ student reviews of thousands of MOOCs. NPTEL Vidoes COMP_SCI_ENGG Coursera.org edX MOOC.fi: Free online courses from the University of Helsinki Udacity Kadenze | Creative Programming: Programming courses focused on art and creativity UCBerkeley MIT OCW Electrical Engineering and Computer Science CS50 prakhar1989/awesome-CS-courses: List containing large amount of CS courses Computer Science Resources: list of MOOCs for autodidacts Java Java Revisited: good for learning about Java Language and interview preparation. The Java™ Tutorials: The best tutorials for Java. Java Corner at Artima.com Java Visualizer: helps visualize references , values of variables ect Java Lecture Notes Learning Java: a free online textbook for learning Java Free Online Chapters of Inside the Java Virtual Machine by Bill Venners Understanding JVM Internals How Garbage Collection Works Welcome to JavaWorld.com The Java Memory Model Netbeans Keyboard Shortcuts: Keyboard shortcuts to enhance your productivity when working in Netbeans. XyzWs Java FAQs: large collection of java interview questions Search Open Source Java API: view source of java library and learn how things are implemented. JournalDev - Java, Java EE, Android, Web Development Tutorials Implementation of Algorithms and Data Structures, Interview Questions and Answers what-is-garbage-collection: Demystify the garbage collection Best books for learning java must read: Get basics of Java Garbage collection (Java); Augmenting data str (video) Compilers (video) Deep Dive Java: Garbage Collection is Good! The C++ Programming Language: The C++ Programming Language. Bjarne Stroustrup's FAQ: The C++ FAQ Bjarne Stroustrup's C++ Style and Technique FAQ: The C++ FAQ C++11 - the new ISO C++ standard: The C++11 FAQ AI Unsupervised Sentiment Neuron: Unsupervised Sentiment Neuron Robots that learn: Robots that Learn grakn.ai: The Database for AI 学习写作 Advice on Research and Writing Seminar and reports PHD MS Articles Practical Tips for Talking at Usergroups and Conferences and Giving presentation on software project to non-programmers YouTube 频道 Computerphile: Must watch for every CS student ComputerHistory: for those who like to know how we reached where we are. GoogleTechTalks: videos on trending topics and cool stuff happening in the tech industry. Placement Grid: Interview and campus placement experience Google Developers Facebook Developers O'Reilly: interviews and talks of world's best technical writers. Java: talks related to java JavaOne: Java Conference CppCon: C++ Conference C++Now (BoostCon): C++Now (previously BoostCon) conference Meeting C++ YT Kanalseite: Talks on C++ ThinMatrix: blogs and tutorials developer making a 3d game in Java using opengl yegor256 Scott Meyers: Past Talks thoughtbot: talks on various topics code::dive conference: code::dive conference organized by NOKIA Wrocław Technology Center HowToBecomeTV: contains good interviews of developers and people related to tech industry. Siraj Raval: Artificial Intelligence and deep learning tutorials videos Netflix UI Engineering: great videos to watch for web developers, mobile developers and those interested in some of Netflix's tech stack Coding Blocks: Tutorials, how to's, tips and tricks Fun Fun Function: A weekly series from Mattias Petter Johansson on an assortment of programming topics, including some not directly related to coding. 一些文章集合 Expectations of a Junior Developer The Key To Accelerating Your Coding Skills A Software Developer’s Reading List: Some good books and links in there. 40 Keys Computer Science Concepts Explained In Layman’s Terms What every programmer should know about memory, Part 1 We are reinventing the retail industry through innovative technology Unicode What every programmer absolutely, positively needs to know about encodings and character sets to work with text List of algorithms Dive into the byte code Data Structure Map A Gentle Introduction To Graph Theory Linux Inside A programmer friendly language that compiles to Lua. 播客 Coding Blocks - Learning principles, patterns and better practices on the go MS Dev Show The Cynical Developer Herding Code Code Newbie Software Engineering Radio: A podcast targeted at the professional software developer. The goal is to be a lasting educational resource, not a newscast. JavaScript Jabber: A weekly discussion about JavaScript, front-end development, community, careers, and frameworks. Developer Tea: A podcast for developers designed to fit inside your tea break. Full Stack Radio: Everything from product design and user experience to unit testing and system administration. Software Engineering Daily: A daily technical interview about software topics The Bike Shed: Guests discuss their development experience and challenges with Ruby, Rails, JavaScript, and others. The Changelog: A weekly conversation that gets to the heart of open source technologies and the people who create them. Front End Happy Hour: A podcast featuring a panel of Software Engineers from Netflix, Evernote, Atlassian & LinkedIn talking over drinks about all things Front End development. 构建一个简单的编译器/解释器 Awesome Compilers: Curated list of awesome resources on Compilers, Interpreters and Runtimes. Resources for Amateur Compiler Writers Possibly the smallest compiler ever Writing My First Compiler Structure and Interpretation of Computer Programs Let’s Build A Simple Interpreter. Part 1. Growing a compiler 教程 Subtle | Poor Man's CI: Learn how continuous integration platforms work under the hood, by building one of your own on top of git with Node.js Tutorialspoint W3Schools Online Web Tutorials Open Data Structures: Excellent resource for learning about DS and algos , provides code in various languages C++ , Java , pseudocode Data Structures and Algorithms by John Morris: another good source with code and its analysis CMSI 281: Data Structures: light weight introduction to DS How to Program in C++: Good resource for revising C++ topics and STL TopCoder Tutorials A Hacker's Guide to Git: for those wanting to learn git with a solid foundation Git from the inside out Learn UNIX in 10 minutes The Bash Guide: very good guide for learning the Bash Shell Linux Tutorial: good resource for learning Linux UNIX Tutorial - Introduction Linux Tutorial for Beginners Learning the shell. Dynamic programming - PrismoSkills: very good resource if want to learn how to solve DP problems. Deep C: very good presentation on C language C programming language Frequently Asked Questions OS Course Notes: Chapter wise course notes according to Galvin's book SQL (Structured Query Language) in one page : SQL.SU: a very good SQL cheat sheet Introduction to C Programming MySQL Essentials http://www.mysqltutorial.org/ Best Of - Gustavo Duarte: contains articles on various topics Collecting all the cheat sheets: cheat sheets for lots of programming languages The Descent to C: for those moving to C from some higher programming language like java or python. VimTutor+: learn VIM from browser itself Linux Journey: good site for learning linux C Programming CS 2112/ENGRD 2112 Fall 2015: Good notes on data structures and algorithms. More about Github-flavored markdown The Unix Programming Environment The Linux Command Line: A Complete Introduction TCP/IP Illustrated Series Head First Design Patterns Design Patterns: Elements of Reusable Object-Oriented Software: aka the "Gang Of Four" book, or GOF UNIX and Linux System Administration Handbook, 4th Edition Programming, Web Development, and DevOps news, tutorials and tools for beginners to experts 阅读他人的代码 LiveEdu.tv: screencast of people building application, websites, games, ect. 程序员须知 Programmer Competency Matrix: article for knowing what our level as a programmer is. GitHub.com Build software better, together: Place to showcase your project and collaborate with others. (Must know Git in order to use it effectively) Gitlab offers free unlimited (private) repositories and unlimited collaborators. 编程比赛 WakaTime: leaderboards of coding metrics collected via editor plugins HackerRank Codeforces topcoder UVa Online Judge: hundreds of problems supporting multiple languages. HackerEarth - Programming challenges and Developer jobs CodeChef PKU ACM ICPC Practice problems Archived Problems - Project Euler Google Code Jam Practice and: past contest problems for practice Sphere Online Judge (SPOJ) Art of Problem Solving Riddles.io AI Games: Compete with your bot and dominate the leaderboards! Codingame: Learn coding through games and challenges! Codewars: Rank up by completing code kata Codefights: Test your coding skills 计算机图书 IT eBooks - Free Download - Big Library: website for downloading ebooks without any advertisement and instant downloads. github.com/vhf/free-programming-books: More than 500 free ebooks on almost any language you can think of Computer Science Books Online: about 150 computer free ebooks Best books for GATE CSE cses.fi/book.html Become a Programmer, Motherfucker (list of books): Exhaustive list of books from Zed A. Shaw. 视频教程 Tushar Roy: Algorithm and Data structure tutorial by an Indian Youtuber. Derek Banas: good quality tutorials thenewboston: good but with too much talk as compared to actual content mycodeschool: Data structures and algorithms tutorials CodingMadeEasy: C++ tutorials XDA-University - Helping You Learn Android Development DevTips: web dev tutorials codedamn: front end web dev tutorials Design and Analysis of Algorithms Vim Tutorial Videos - Flarfnoogins: good video tutorial for learning vim CS1: Higher Computing - Richard Buckland UNSW: a very good introductory CS course Kathryn Hodge: Has good videos for beginners 在线编译 CodePad: Code editor to try, test and run 25+ languages JSFiddle: Test your JavaScript, CSS, HTML or CoffeeScript with online code editor Ideone.com: online compiler and debugging tool for more than 60 programming languages Pastebin.com Godbolt.org: Excellent tool for exploring the assembly output of different compilers with and without optimization. 一些不错的博客 Coding Horror: one the best coding blog WildMl: A blog for machine learning. Armin Ronacher's Thoughts and Writings: blog on Python and open source Eli Bendersky: everything from Python to LLVM Joel on Software Stephen Haunts { Coding in the Trenches } Programming in the 21st Century Clean Coder Blog: blog of author of book "Clean Code" Programming Blog: programming blog of Yegor Bugayenko CodeAhoy: Blog on software and human factors. 100% Tested on Humans. stevehanov.ca Geek Land Late Developer IT Enthusiast blog.might.net CSE Blog - quant, math, computer science puzzles Small Programming Challenges and Puzzles My Tech Interviews HackerEarth Blog Algo-Geeks CoderGears Blog Insights from: the CoderGears Team Runhe Tian Coding Practice Paul Graham Essays Dan Dreams of Coding Antonio081014's Algorithms Codes Math ∩ Programming Takipi Blog: mainly focuses on Java and JVM languages Coding Geek - A blog about IT, programming and Java Daedtech.com: Stories about software Archives — Ask a Manager: HR related stuff 英语学习 Quia - English Punctuation and Capitalization Rules Guide to Grammar and Writing: for those who want to improve their english language skills Purdue University Online Writing Lab (OWL) Englishclub.com/learn-english 无聊时可以看看这些 r/ProgrammerHumor: Subreddit dedicated to exactly what it sounds like Vsauce: The best youtube channel TED: Great talks about technology, entertainment, and design CrashCourse: small courses on various subjects National Geographic: High volume of high quality content from all over the world Barcroft TV: Daily short documentaries about the incredible variety of people that make up the world ColdFusion: Past, present, and future of technology SmarterEveryDay: Lots of amazing scientific information about the world around us, usually captured with a high-speed camera SciShow: Answers to interesting questions that you've always wondered about Big Think: Expert driven, actionable, educational content, featuring experts ranging from Bill Clinton to Bill Nye Every Frame a Painting: High quality analysis of films and filmmaking TestTube News: Interesting information about news from around the world Reddit the front page of the internet: Where free time goes to die

资源下载

更多资源
腾讯云软件源

腾讯云软件源

为解决软件依赖安装时官方源访问速度慢的问题,腾讯云为一些软件搭建了缓存服务。您可以通过使用腾讯云软件源站来提升依赖包的安装速度。为了方便用户自由搭建服务架构,目前腾讯云软件源站支持公网访问和内网访问。

Rocky Linux

Rocky Linux

Rocky Linux(中文名:洛基)是由Gregory Kurtzer于2020年12月发起的企业级Linux发行版,作为CentOS稳定版停止维护后与RHEL(Red Hat Enterprise Linux)完全兼容的开源替代方案,由社区拥有并管理,支持x86_64、aarch64等架构。其通过重新编译RHEL源代码提供长期稳定性,采用模块化包装和SELinux安全架构,默认包含GNOME桌面环境及XFS文件系统,支持十年生命周期更新。

Sublime Text

Sublime Text

Sublime Text具有漂亮的用户界面和强大的功能,例如代码缩略图,Python的插件,代码段等。还可自定义键绑定,菜单和工具栏。Sublime Text 的主要功能包括:拼写检查,书签,完整的 Python API , Goto 功能,即时项目切换,多选择,多窗口等等。Sublime Text 是一个跨平台的编辑器,同时支持Windows、Linux、Mac OS X等操作系统。

WebStorm

WebStorm

WebStorm 是jetbrains公司旗下一款JavaScript 开发工具。目前已经被广大中国JS开发者誉为“Web前端开发神器”、“最强大的HTML5编辑器”、“最智能的JavaScript IDE”等。与IntelliJ IDEA同源,继承了IntelliJ IDEA强大的JS部分的功能。

用户登录
用户注册