Flask

ssl.SSLCertVerificationError for flask application OAuth login with keycloak

心已入冬 提交于 2021-02-07 14:16:55
问题 I have referred a sample hello-world flask app integrated with key-cloak login from https://gist.github.com/thomasdarimont/145dc9aa857b831ff2eff221b79d179a My client-secrets.json is as follows: { "web": { "issuer": "https://keycloak-keycloak.router.default.svc.cluster.local.167.254.224.26.nip.io/auth/realms/myrealm", "auth_uri": "https://keycloak-keycloak.router.default.svc.cluster.local.167.254.224.26.nip.io/auth/realms/myrealm/protocol/openid-connect/auth", "client_id": "myclient", "client

UndefinedError: 'current_user' is undefined

為{幸葍}努か 提交于 2021-02-07 13:59:09
问题 I have a app with flask which works before But Now I use Blueprint in it and try to run it but got the error so i wonder that is the problem Blueprint that g.user Not working? and how can I fix it Thnx :) app/layout/__ init __.py : from flask import Blueprint layout = Blueprint('layout', __name__) from . import view __ init __ .py from flask import Flask from flask.ext.sqlalchemy import SQLAlchemy from flask.ext.login import LoginManager import psycopg2 from config import basedir from config

Overriding Flask-User/Flask-Login's default templates

馋奶兔 提交于 2021-02-07 13:31:47
问题 I have found a similar question here, but the answer does not seem to work for me. I use Flask User (which extends Flask Login, I believe) and for the most part it works very well. I have built my own completely fresh templates for sign in and registration, rather than using their provided ones. Following the documentation, I have placed these templates at templates/flask_user/login.html , templates/flask_user/register.html and so on. I have also set USER_UNAUTHENTICATED_ENDPOINT = "login"

Why do I get a “404 Not Found” error even though the link is on the server?

对着背影说爱祢 提交于 2021-02-07 12:03:19
问题 I'm running a simple test site on PythonAnywhere using Flask. When I run the script, the initial site (index.html) appears, and everything seems fine. However, when I click on any of the links (like signup.html), I get a 404 error: Not Found The requested URL was not found on the server. If you entered the URL manually please check your spelling and try again. However, the HTML files are all in the templates folder, along with index.html. Why can't they be found on the server? Here is the

Can an uploaded image be loaded directly by cv2?

可紊 提交于 2021-02-07 11:51:51
问题 I have an uploaded file in memory. I want to manipulate the file with cv2. Currently, I write the file to disk then read it with cv2. How can I skip writing the file and load it directly with cv2? file = request.files['file'] # if file and allowed_file(file.filename): # save file filename = secure_filename(file.filename) file_path = os.path.join(dressrank.config['SHOW_IMG_FOLDER'], filename); file.save(file_path) img_path = file_path # COLOR FATURE EXTRACTION img = read_img(img_path) img =img

Serving static files from static folder with Flask [duplicate]

心不动则不痛 提交于 2021-02-07 10:54:09
问题 This question already has answers here : Link to Flask static files with url_for (2 answers) How to serve static files in Flask (19 answers) Closed 1 year ago . I am attempting to serve static mp3 files with Flask so I can embed these mp3 files in an HTML audio block. I seem to be having an issue setting up the path correctly but I am not entirely sure if my problem is in my python or html. An outline of my project: music app.py static button.js MDF.mp3 templates button.html My app

Serving static files from static folder with Flask [duplicate]

社会主义新天地 提交于 2021-02-07 10:53:46
问题 This question already has answers here : Link to Flask static files with url_for (2 answers) How to serve static files in Flask (19 answers) Closed 1 year ago . I am attempting to serve static mp3 files with Flask so I can embed these mp3 files in an HTML audio block. I seem to be having an issue setting up the path correctly but I am not entirely sure if my problem is in my python or html. An outline of my project: music app.py static button.js MDF.mp3 templates button.html My app

Python: Not getting the response for Message Back action in MS Teams Adaptive Cards

感情迁移 提交于 2021-02-07 10:44:17
问题 I am new to Python and have been trying to integrate it with MS Teams using an outgoing webhook. I have created a simple web service to handle post request using flask and I am hosting it using ngrok and the resulting URL from ngrok have been used as the Outgoing webhook callback URL in teams. I am able to receive message in my service and send an adaptive card as response. But if I fill out the information and click Submit I get 'Something went wrong. Please try again' error and I am not

Flask HTML Escape Decorator

蓝咒 提交于 2021-02-07 09:51:52
问题 How would I use a decorator on a route to HTML escape its output. That is, how do I write the html_escape function here: @app.route('/') @html_escape def index(): return '<html></html>' (I feel like there should be an extension for this and other simple decorators) 回答1: Flask has its own escape , doc: flask.escape so, you can: from flask import escape @app.route('/') def index(): return escape("<html></html>") if you insist on using decorator: from functools import wraps from flask import

Flask-SQLAlchemy database engine returns table names, but the table keys in metadata are empty

倾然丶 夕夏残阳落幕 提交于 2021-02-07 09:25:24
问题 I am connected to a MS SQL Server. The following returns all the table names in the database: app.config.from_object('config') db = SQLAlchemy(app) db.engine.table_names() However, this doesn't: db.metadata.tables.keys() // returns: dict_keys([]) Similarly, this doesn't work: db.table('dbo.users').primary_key // returns: ColumnSet([]) However, I am able to execute SQL queries. What would be the problem? 回答1: Engine.table_names gives you a list of available table names from the database.