Category: Flask

Is there a way to use Bootstrap toast in Flask flashing natively?

Query asked by user I want to show toast messages using flash() method in Flask. I know that Bootstrap alerts work, so I used the same logic and replaced the code for alerts with toasts. But it does not seem to work for me. app.py @app.route(‘/’, methods=[‘GET’, ‘POST’]) def home(): if request.method == ‘GET’: flash(‘This […]

Angular/Flask http post doesn’t work, data hasn’t been sent

Query asked by user It seems like http post doesn’t send the data to server. I think I forgot something, but can’t see what. Here my service passChosenSymtom(symptoms:any){ console.log(symptoms) const lol={symptoms: symptoms}//consider lol={‘x’:[0,1]} console.log(JSON.stringify(lol)) return this.http.post(this.resultatSymptoms2,JSON.stringify(lol)) } Component getResult(){ this.symps.passChosenSymtom(this.allDisease).subscribe({ next: (obj) => this.assignmentForResult(obj), error: (e) => console.error(e), complete: () => console.info(‘complete’) } ) } […]

Html form (popup) with javascript and flask

Query asked by user I’m trying to create a simple todo flask app. It is linked with a database with columns id, content(task) and status(todo, progress, done). I added features like add a new task, delete it and update its status with buttons. I’m trying to add an “edit task” button trough a popup form. […]

Response to preflight request doesn’t pass access control check: It does not have HTTP ok status in angular

Query asked by user i’m developing a website with angular as and flask as backend, i’ve used flask-cors on backend and have set up proxy on frontend using tutorial on this link https://www.positronx.io/handle-cors-in-angular-with-proxy-configuration/#:~:text=Enable%20CORS%20with%20Proxy%20Configuration%20Settings%20in%20Angular.&text=To%20enable%20CORS%20via%20proxy,the%20deliberate%20use%20of%20SSL. but I always get an error like the following. Please help me solve this problem, thanks error : Access to XMLHttpRequest at […]

Issues getting Flask-PyMongo and Flask-Cors to work in my venv

Query asked by user I just started the app with the following code: from flask import Flask, request, jsonify from flask_pymongo import PyMongo, ObjectId from flask_cors import CORS app = Flask(__name__) app.config[“MONGO_URI”]=”mongodb://localhost/crudapp” mongo = PyMongo(app) CORS(app) db = mongo.db.users if __name__ == “__main__”: app.run(debug = True) In my explorer I have something like: >Project Folder […]

Do CORS restrictions apply to browser windows as well ? HTML Editor:127.0.0.1:5000, Img editor:127.0.0.1:8000. Sending img results back causes a CORS

Query asked by user I have a app on 127.0.0.1:5000 that edits a page (html code) If I need to edit a picture on that page using a specialized editor I select the picture and then I fire up a call to 127.0.0.1:8000/picture_editor?picture_url=”127.0.0.1:5000/static/uploads/picture.jpg All good so far, I am able to edit the picture and […]

Flask webpage not displaying newline on output

Query asked by user When adding \n to my output variable, no newline is being added on the webpage. In my app.py my page looks as follows(for example purposes, I took out user input): (@)app.route(‘/update-form’, methods=[“POST”]) def update_form(): output=str() output += “hostname updated successfully ” output += “\nhostname 2 updated successfully” return render_template(“update-success.html”, output=output) Then […]

Is there anyway to know at which card “add comment” has clicked using flask

Query asked by user I’m trying to add a comment section to my web app however, I want to know which book its “add comment” has clicked I’m thinking about getting the book’s ID. Here is my python @app.route(“/comment”, methods=[“GET”, “POST”]) def comment(): if request.method == “POST”: if not request.form.get(“comment”): return apology(“must provide comment”, 400) […]

How to assign a function to a route functionally, without a route decorator in FastAPI?

Query asked by user In Flask, it is possible to assign an arbitrary function to a route functionally like: from flask import Flask app = Flask() def say_hello(): return “Hello” app.add_url_rule(‘/hello’, ‘say_hello’, say_hello) which is equal to (with decorators): @app.route(“/hello”) def say_hello(): return “Hello” Is there such a simple and functional way (add_url_rule) in FastAPI? […]