werkzeug

Can't run Flask debug mode on Google App Engine

时间秒杀一切 提交于 2019-12-10 18:19:32
问题 I'm running Flask 0.9 / Werkzeug 0.8.3 on Google App Engine with Python 2.7, and I desperately want Werkzeug debugger running. After trying to use werkzeug_appengine_debugger I have the following exception in console: File "/path/to/application/main.py", line 14, in <module> @app.route('/') AttributeError: 'DebuggedApplication' object has no attribute 'route' It can be not only 'route', but whatever attribute Flask application can have. My file tree looks like this, borrowed from flask

Flask auto-reload and long-running thread

久未见 提交于 2019-12-10 16:13:40
问题 I'm implementing a long-running thread within a Flask application. In debug mode, with the reloader activated, the long-running thread is not killed upon reload. Instead, because the code that creates and starts the thread is run after reloading, each cycle creates an additional thread. How can I prevent this, other than disabling the reloader? Will the same happen when running under mod_wsgi, with its auto-reload feature? Update : the long-running thread was actually killed by Werkzeug upon

Failed to convert object of type <class 'werkzeug.datastructures.File.Storage> to tensor

ぐ巨炮叔叔 提交于 2019-12-10 15:14:45
问题 I am writing a client python file that uses flask framework and running this inside a docker machine. So this take an input file and produces output of it. But it throws error that it cant convert to tensor. tf.app.flags.DEFINE_string('server', 'localhost:9000', 'PredictionService host:port') FLAGS = tf.app.flags.FLAGS app = Flask(__name__) class mainSessRunning(): def __init__(self): host, port = FLAGS.server.split(':') channel = implementations.insecure_channel(host, int(port)) self.stub =

Threads and local proxy in Werkzeug. Usage

江枫思渺然 提交于 2019-12-10 13:20:30
问题 At first I want to make sure that I understand assignment of the feature correct. The local proxy functionality assigned to share a variables (objects) through modules (packages) within a thread. Am I right? At second, the usage is still unclear for me, maybe because I misunderstood an assignment. I use Flask. If I have two (or more) modules: A, B. I want to import object C from module A to module B. But I can't do it in the usual way, from A import C , because it will cause a looped import

Get the Flask view function that matches a url

浪尽此生 提交于 2019-12-09 15:25:15
问题 I have some url paths and want to check if they point to a url rule in my Flask app. How can I check this using Flask? from flask import Flask, json, request, Response app = Flask('simple_app') @app.route('/foo/<bar_id>', methods=['GET']) def foo_bar_id(bar_id): if request.method == 'GET': return Response(json.dumps({'foo': bar_id}), status=200) @app.route('/bar', methods=['GET']) def bar(): if request.method == 'GET': return Response(json.dumps(['bar']), status=200) test_route_a = '/foo/1' #

werkzeug.security generate_password_hash alternative without SHA-1

孤人 提交于 2019-12-09 09:47:57
问题 I use generate_password_hash from werkzeug.security to hash and salt my passwords. I recently saw this article about SHA-1 collisions. werkzeug.security uses SHA-1 and since it is not as safe any more I would like an alternative. How can I hash my passwords without relying on SHA-1? from werkzeug.security import generate_password_hash generate_password_hash(secret) 回答1: The use of SHA-1 in generate_password_hash is not vulnerable , as it is only used as an intermediate, iterated step in the

cleaning up my SQLAlchemy operations (reducing repetition)

别等时光非礼了梦想. 提交于 2019-12-07 18:42:40
问题 I have some server side processing of some data (client-side library = jQuery DataTables ) I am using POST as my ajax method. In my Flask webapp, I can access the POST data with request.values The data type / structure of request.values is werkzeug.datastructures.CombinedMultiDict If the user wants to sort a column, the request contains a key called action with a value of filter (note the below printouts are obtained with for v in request.values: print v, request.values[v] ) ... columns[7]

flask deployment using internal werkzeug development server

假如想象 提交于 2019-12-07 17:32:16
问题 Why is it not recommended to use the flask/werkzeug internal development webserver in production? What sort of issues can arise? I'm asking because in work I'm being forced to do so and use a make shift cron to re-run the service every day! 回答1: If you're having to use a cron job to kill & restart it on a daily basis, you've already found a major issue with using the Flask development server. The development server is not written for stability, longevity, configurability, security, speed or

url structure and form posts with Flask

我怕爱的太早我们不能终老 提交于 2019-12-07 06:33:37
问题 In Flask you write the route above the method declaration like so: @app.route('/search/<location>/') def search(): return render_template('search.html') However in HTML as form will post to the url in this fashion www.myapp.com/search?location=paris the latter seems to return a 404 from the application where www.myapp.com/search/london will return as expected. I'm sure that there is a simple piece of the puzzle that i'm not getting, but surely the routing engine will consider the query string

Flask app wrapped with DispatcherMiddleware no longer has test_client

送分小仙女□ 提交于 2019-12-07 04:12:55
问题 We can obtain test_client for sample application in way like: class MyTestCase(unittest.TestCase): @classmethod def setUpClass(cls): my_app.app.config['TESTING'] = True cls.client = my_app.app.test_client() However, if we wrap app with DispatcherMiddleware - we will get error like AttributeError: 'DispatcherMiddleware' object has no attribute 'test_client' . Are there way to test composition of flask applications? We want to be able to do something like: cls.client = my_app.all_apps.test