Posts

Showing posts with the label flask

Typerror() in python while passing parameters to the route [duplicate]

Image
Clash Royale CLAN TAG #URR8PPP Typerror() in python while passing parameters to the route [duplicate] This question already has an answer here: I need to pass parameter to routes using url_for() function and redirect() I think I did the same. But, I get TypeError: book() missing 1 required positional argument: 'book_title' I know that the parameter book_title is not being recieved by the book() function in my code and thats why the error. But, I dont know what's going wrong behind the scenes. These are my routes url_for() redirect() TypeError: book() missing 1 required positional argument: 'book_title' book_title book() @app.route('/search/<title>/',methods=['GET','POST']) def btitle(title): book_title = db.execute("SELECT title,author,isbn from books WHERE (title LIKE :title)",params={"title":title}).fetchall() if request.method == 'GET': #book_title = db.execute("SELECT title,autho...

how do i process a file while making a flask server?

Image
Clash Royale CLAN TAG #URR8PPP how do i process a file while making a flask server? I have my code her. I was wondering how do I get this file to even be recognized or saved as a local variable in the Python code? (the file is a csv btw). Here is the image from flask import Flask from flask_restful import Api, Resource, reqparse app = Flask(__name__) api = Api(app) class Dataframe(Resource): def post(self, name): parser = reqparse.RequestParser() parser.add_argument("data") args = parser.parse_args()[enter image description here][1] return args, 201 api.add_resource(Dataframe, "/<string:name>") app.run(debug=True) By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Dash callbacks not working, if dash app is created and called from flask

Image
Clash Royale CLAN TAG #URR8PPP Dash callbacks not working, if dash app is created and called from flask Dash app fails, when it is created and called through the flask sever. Dash 'Callback’s are not working and gives Post Request 400. Any help is much appreciated. A sample code to reproduce the problem is below. I use latest Dash 0.22.0, Dash HTML Components 0.11.0, and Dash Core Components 0.24.1, and Flask 1.0.2: # file 'simple_flask.py' from flask import Flask from flask_sqlalchemy import SQLAlchemy from flask_wtf.csrf import CSRFProtect # Initialise flask App app = Flask(__name__, instance_relative_config=True) #app.config.from_object('config.Config') db = SQLAlchemy() # SQLAlchemy csrf_protect = CSRFProtect() def set_app(app): # Setup WTForms CSRFProtect app.secret_key = 'My super secret key' csrf_protect.init_app(app) # Setup Flask-SQLAlchemy db.init_app(app) # run in app context with app.test_request_context(): ...

Flask-SQLAlchemy TimeoutError

Image
Clash Royale CLAN TAG #URR8PPP Flask-SQLAlchemy TimeoutError My backend configuration is : I've got this error message: TimeoutError: QueuePool limit of size 5 overflow 10 reached, connection timed out, timeout 30 Do I need to close explicitly the db.session? Shouldn't be the connection back to pool when session goes out of scope? 4 Answers 4 This could happen if you are using debug=True in your application and you have loaded several pages or API endpoints which errored out. debug=True The reason is that running the debug version of the app keeps a live debugger open in the error page. This live debugger keeps around all the resources from processing the request, so that you can examine them. This means that the database connection can't be recycled. You shouldn't use debug mode for the production version of your app (apart from problems like this it is a security risk), and the ...

How to use lookup filters to sort results in PythonEve using PyMongo

Image
Clash Royale CLAN TAG #URR8PPP How to use lookup filters to sort results in PythonEve using PyMongo In PythonEve using MongoDB, how can I get (internally) the last item created in a given collection? Looking into eve's mongo module find_one_raw looks like the way to go. I am trying something like the following without success: find_one_raw last = app.data.find_one_raw('aresource',**{"_created": {"sort": 1}}) last = app.data.find_one_raw('aresource',**{"_created": {"sort": 1}}) By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.