Flask

Uploading a photo using XMLHtttpRequest to a Flask webserver

☆樱花仙子☆ 提交于 2021-02-08 04:40:28
问题 I'm creating a WinJS app and using XMLHttpRequest to send a photo as a blob to a Flask webserver. openPicker.pickSingleFileAsync().then(function (file) { file.openAsync(Windows.Storage.FileAccessMode.read).done(function (stream) { var blob = MSApp.createBlobFromRandomAccessStream("application/octet-stream", stream); var fdata = new FormData(); fdata.append("file", blob, "photo.jpg"); var xmlhttp = new XMLHttpRequest(); xmlhttp.open("POST", "http://127.0.0.1:5000/api/addPhoto", true); xmlhttp

flask-login invalidates session randomly after authentication

左心房为你撑大大i 提交于 2021-02-08 03:38:48
问题 I'm using flask-login https://flask-login.readthedocs.io/en/latest for session management. The user first login in (login.html) the application and go to home.html. However, after the user has authenticated and click different links, it will kick out the session and go back to login page. This happens very randomly and I'm not sure what went wrong? It is using apache. It seems okay with localhost but having this issue in apache. Are there specific apache configurations need to pay attention?

flask-login invalidates session randomly after authentication

假如想象 提交于 2021-02-08 03:38:32
问题 I'm using flask-login https://flask-login.readthedocs.io/en/latest for session management. The user first login in (login.html) the application and go to home.html. However, after the user has authenticated and click different links, it will kick out the session and go back to login page. This happens very randomly and I'm not sure what went wrong? It is using apache. It seems okay with localhost but having this issue in apache. Are there specific apache configurations need to pay attention?

Remove old temporary files when user is logged out

我是研究僧i 提交于 2021-02-08 02:59:24
问题 I have a view that takes logged in user input then runs a function to produce a report. The result is returned in an HTML page. I render the report to PDF as well. I create a PDF with the content from my function and save it in some folder on the server. I don't want to have my server filled with files from every run, so I create a temporary folder (in tmpfs) for each user when they log in and save the path in their session, which is not permanent. session['temp_path'] = '/dev/shm/<random

Flask, Windows, IIS, Plotly-Dash. Error Occured While reading WSGI handler

大兔子大兔子 提交于 2021-02-08 02:23:00
问题 I'm hoping you can help me with errors that I'm getting with Flask in an attempt to deploy plotly-dash on a Windows server. I've set up Flask using the following guide, verbatim, except the location of my website within the wwwroot folder: Flask on IIS When I use the most basic of apps, it works fine, an example being the following code: from flask import Flask app = Flask(__name__) @app.route("/") def hello(): return "Hello from FastCGI via IIS!" if __name__ == "__main__": app.run() But then

Flask, Windows, IIS, Plotly-Dash. Error Occured While reading WSGI handler

巧了我就是萌 提交于 2021-02-08 02:20:33
问题 I'm hoping you can help me with errors that I'm getting with Flask in an attempt to deploy plotly-dash on a Windows server. I've set up Flask using the following guide, verbatim, except the location of my website within the wwwroot folder: Flask on IIS When I use the most basic of apps, it works fine, an example being the following code: from flask import Flask app = Flask(__name__) @app.route("/") def hello(): return "Hello from FastCGI via IIS!" if __name__ == "__main__": app.run() But then

Adding Google Fonts to Flask

限于喜欢 提交于 2021-02-07 20:36:56
问题 So with flask I know that I can add CSS with <link ... href="{{ url_for('static', filename='stylesheets/style.css') }}" /> but if I am adding a google font which usually in HTML looks like <link href='http://fonts.googleapis.com/css?family=PT+Sans:400,700' rel='stylesheet' type='text/css'> what do I need to edit/add for it to work with Flask? 回答1: You can't use static here like you would normally for a link to a resource on the webserver. Your link is still essentially static but not related

Why does Header Content-Type for POST request differ between chrome and firefox only in by “UTF-8” vs “utf-8”?

耗尽温柔 提交于 2021-02-07 20:19:41
问题 I am using Flask and Angular JS to process POST request and I am wondering why the Chrome request header has application/json;charset=UTF-8 compared to FireFox application/json;charset=utf-8 . Note the difference is only the chrome capitalizes UTF while FireFox doesnt (utf). This is probably related to SO: MySQL UTF8 for Chrome, UTF8 for IE, but HEADER UTF8 for Chrome and UTF-8 for IE? but I wasn't able to understand completely. I am not using any meta tag in the html, maybe that is the

Safe way to store mysql server credentials in flask?

被刻印的时光 ゝ 提交于 2021-02-07 19:58:05
问题 I was wondering about the safety of some thing in my app.py flask app. First the database, I'm using mysql and currently I am connecting to it in the following way: # Config MySQL app.config['MYSQL_HOST'] = 'localhost' app.config['MYSQL_USER'] = 'root' app.config['MYSQL_PASSWORD'] = 'password' app.config['MYSQL_DB'] = 'databasename' app.config['MYSQL_CURSORCLASS'] = 'DictCursor' And to me this feels very weird, just putting in your password in plain text etc. I've been searching online but

Safe way to store mysql server credentials in flask?

夙愿已清 提交于 2021-02-07 19:55:22
问题 I was wondering about the safety of some thing in my app.py flask app. First the database, I'm using mysql and currently I am connecting to it in the following way: # Config MySQL app.config['MYSQL_HOST'] = 'localhost' app.config['MYSQL_USER'] = 'root' app.config['MYSQL_PASSWORD'] = 'password' app.config['MYSQL_DB'] = 'databasename' app.config['MYSQL_CURSORCLASS'] = 'DictCursor' And to me this feels very weird, just putting in your password in plain text etc. I've been searching online but