Flask

全了!从Python入门到入魔

天涯浪子 提交于 2020-12-27 10:12:28
总被读者问到,我看完了python入门的书,后面就不知道要学什么了。今天就给你们整理全套入门到进阶的教程。 这套教程非常全面而且详细,从 Python入门 到 Python进阶 、 Django 、 Flask等Web框架以及爬虫、数据库、算法与数据结构 等方面均有涉及,几乎覆盖了Python 基础及进阶的方方面面。 让你学完之后能独立完成一个完整的项目。 简明Python入门教程 Python进阶教程 Django入门与实践 用 Flask 从零开始搭建网站 Linux操作系统 HTTP入门指南 MySQL数据库面试汇总 520道LeetCode算法刷题 245道Python面试题 现在以上全套教程和思维导图均可免费获取。 如何获取? 1. 识别并关注公众号「 秦子帅 」; 2. 在下面公众号后台回复关键字「 教程 」。 👆 长按上方二维码 2 秒 回复「 教程 」即可获取资料 额外福利 今天给大家分享一份 11 月刚刚出炉的《TensorFlow 2.0 深度学习算法实战》中文版教材。 所有的项目都是 基于TensorFlow 2.0实战。 获取方法 《TensorFlow 2.0 深度学习算法实战》中文版教材电子版 pdf 已经打包好,获取步骤如下: 1. 扫描下方二维码 2. 后台回复关键词: TF2 👆长按上方二维码 2 秒 回复「 TF2 」即可获取资料

ValueError: Shape of passed values is (1, 6), indices imply (6, 6)

↘锁芯ラ 提交于 2020-12-27 08:48:57
问题 I am passing a list from flask function to another function, and getting this value error. My code at sending end: @app.route('/process', methods=['POST']) def process(): name = request.form['name'] comment = request.form['comment'] wickets = request.form['wickets'] ga = request.form['ga'] ppballs = request.form['ppballs'] overs = request.form['overs'] score = [name,comment,wickets,ga,ppballs,overs] results = [] results = eval_score(score) print results Receiver end : def ml_model(data): col

flask-login: Chrome ignoring cookie expiration?

ⅰ亾dé卋堺 提交于 2020-12-27 08:15:38
问题 I've got the authentication working with flask-login, but it seems like no matter what I use for the cookie duration in flask, the session is still authenticated. Am I setting the config variables properly for flask-login? I've tried app.REMEMBER_COOKIE_DURATION = datetime.timedelta(seconds=30) app.config["REMEMBER_COOKIE_DURATION"] = datetime.timedelta(seconds=30) Even if I close the browser, wait a while, and hit a url that should be protected, I can still access it. Is this related to this

flask-login: Chrome ignoring cookie expiration?

百般思念 提交于 2020-12-27 08:14:24
问题 I've got the authentication working with flask-login, but it seems like no matter what I use for the cookie duration in flask, the session is still authenticated. Am I setting the config variables properly for flask-login? I've tried app.REMEMBER_COOKIE_DURATION = datetime.timedelta(seconds=30) app.config["REMEMBER_COOKIE_DURATION"] = datetime.timedelta(seconds=30) Even if I close the browser, wait a while, and hit a url that should be protected, I can still access it. Is this related to this

flask-login: Chrome ignoring cookie expiration?

余生颓废 提交于 2020-12-27 08:13:04
问题 I've got the authentication working with flask-login, but it seems like no matter what I use for the cookie duration in flask, the session is still authenticated. Am I setting the config variables properly for flask-login? I've tried app.REMEMBER_COOKIE_DURATION = datetime.timedelta(seconds=30) app.config["REMEMBER_COOKIE_DURATION"] = datetime.timedelta(seconds=30) Even if I close the browser, wait a while, and hit a url that should be protected, I can still access it. Is this related to this

JavaScript Blob to download a binary file creating corrupted files

被刻印的时光 ゝ 提交于 2020-12-27 06:20:10
问题 I have a binary file (python pickle file, to be exact). Whenever such a file is requested, I create one on server side, and then send it to the client via flask's send_file as an AJAX request. Next, I need to download this file automatically to the client side, so I have used this answer. The problem is that, the created file on the server normally has a size 300 Bytes, and the file downloaded on the client side is of the size >500 Bytes. Plus whenever I try to reuse the pickle file, it doesn

JavaScript Blob to download a binary file creating corrupted files

∥☆過路亽.° 提交于 2020-12-27 06:12:34
问题 I have a binary file (python pickle file, to be exact). Whenever such a file is requested, I create one on server side, and then send it to the client via flask's send_file as an AJAX request. Next, I need to download this file automatically to the client side, so I have used this answer. The problem is that, the created file on the server normally has a size 300 Bytes, and the file downloaded on the client side is of the size >500 Bytes. Plus whenever I try to reuse the pickle file, it doesn

Displaying JSON in the HTML using flask and local JSON file

时光怂恿深爱的人放手 提交于 2020-12-26 12:22:08
问题 I work with the Python flask, HTML, and local JSON file to display the JSON data from a local JSON file in the HTML. Once the flask reads a local JSON file, it is sent to index.html with jsonify. After then, using that data I want to display the information. I can the JSON data in the flask side, but have struggled with displaying it in the HTML. Could you let me know what I missed? flask code import os from flask import Flask, render_template, abort, url_for, json, jsonify import json import

During a long-running process, will Flask be insensitive to new requests?

喜夏-厌秋 提交于 2020-12-26 08:40:06
问题 My Flask project takes in orders as POST requests from multiple online stores, saves those orders to a database, and forwards the purchase information to a service which delivers the product. Sometimes, the product is not set up in the final service and the request sits in my service's database in an "unresolved" state. When the product is set up in the final service, I want to kick off a long-running (maybe a minute) process to send all "unresolved" orders to the final service. During this

How to return plain text from flask endpoint? Needed by Prometheus

穿精又带淫゛_ 提交于 2020-12-26 08:04:50
问题 I need to setup a /metrics endpoint so that Prometheus can consume statistics about an endpoint. How do I go about doing this? I have this in my Flask app: @app.route('/metrics') def metrics(): def generateMetrics(): metrics = "" ... some string builder logic return metrics response = make_response(generateMetrics(), 200) response.mimetype = "text/plain" return response Is this the best way? What is the difference between returning a String (just returning metrics here) and returning plain