flask

How to test the python backend of a flask application?

How to test the python backend of a flask application? Question: I have a draft of a flask application with a html/javascript frontend and a python backend, to which the frontend communicates through the flask API. I want to test the python backend using the API using python only (no javascript etc involved in the …

Total answers: 2

Raise HTTPException not being called

Raise HTTPException not being called Question: I have the following code: @events_router.delete("/events/{event_id}", status_code=204) def delete_event(*, event_id: int) -> None: for event in EVENTS: if event[‘id’] == event_id: del EVENTS[event_id-1] print("event id = " + str(event_id) + " deleted!") break raise HTTPException( status_code=404, detail=f"Event with ID {event_id} not found" ) If I add an event and …

Total answers: 1

Javascript to python data is not sent i am using flask and unable to convert

Javascript to python data is not sent i am using flask and unable to convert Question: (comment how can i improve way to present the question as well) I am making a project for typing speed web application using Flask. But the problem is in calculating the time it takes for user to type. I’ve …

Total answers: 1

flask send base 64 encoded pdf string without saving

flask send base 64 encoded pdf string without saving Question: I have a flask application. I am using selenium cdp commands to generate pdfs. I get a base64 encoded string from selenium. Before sending the response as a pdf I save the file in my filesystem. file.write(base64.b64decode(pdf_string[‘data’]) And the response is just send_file(‘path’, ‘name.pdf’) How …

Total answers: 2

Python Flask : request.form, how to get specific value of key?

Python Flask : request.form, how to get specific value of key? Question: with Flask, i m a newbie, so my question is probably stupid. But I cannot understand why the page ‘/result’ is displaying "{resulte}" and not the input from field "Name". I just want the page "result" to show what the user entered in …

Total answers: 2

How to pass file using html form, Dropzone and Flask

How to pass file using html form, Dropzone and Flask Question: I am using Dropzone and Flask using html form to pass files. like this below: <form action="/" enctype="multipart/form-data" method="POST" class="dropzone" id="myAwesomeDropzone" > <div class="fallback"> <input name="file" id="file" type="file" accept=".csv, text/csv, text/plain, text/tsv, text/comma-separated-values" /> </div> <div class="dz-message needsclick"> <i class="h1 text-muted dripicons-cloud-upload"></i> <h3>Drop CSV …

Total answers: 1

Flask Multithreading Issue Not Executing Properly Long Load Time

Flask Multithreading Issue Not Executing Properly Long Load Time Question: Basically, In my flask application, I have a function. In this function, I am sending a request which takes 20 seconds to complete. So I added multithreading to solve this. But for some reason, it is not threading properly and the page load time is …

Total answers: 1

wsgi:error ModuleNotFoundError in my webapp model

wsgi:error ModuleNotFoundError in my webapp model Question: Hello IT ladies and IT gentlemen. Please, help me with non-recognized folder "devices". I have a program for reading data from robot. And data are stored in "devices" folder. My file structure: GRP devices _ _ init _ _.py dev1.py dev2.py dev3.py webapp.py tools _ _ init _ …

Total answers: 1

Flask: Get the function within the before_request

Flask: Get the function within the before_request Question: I want to se a session scope from within a before_request function, so it would act like a yield or a decorator callback: @contextmanager def db_session(): """Provide a transactional scope around a series of operations.""" session = Session() try: yield session session.commit() except Exception as e: session.rollback() …

Total answers: 1

Flask form not validating on submit

Flask form not validating on submit Question: I’m trying to make a form that looks like an exam page. I have a checkbox and a submit button, the submit button when clicked does not do anything. The HTML code in exam.html {% extends ‘layout.html’ %} {% block content %} <h3 class="pt-5 p-4">exam page</h3> <div class="form"> …

Total answers: 1