Flask

How to setup flask-socketio in a docker container?

纵饮孤独 提交于 2021-02-07 19:41:30
问题 Hello I'm trying to setup flask-socketio in a docker container. It seems to run but I get an error( from the browser) when I try to access localhost on port 5000 like I'm used to do with flask apps. It say's: unable to connect! I will show you the 5 important files: Dockerfile, requirements.txt, docker-compose.yml, web_app.py and index.html Dockerfile: FROM python:3.6.5 WORKDIR /code COPY * /code/ RUN pip install -r requirements.txt requirements.txt: Flask==1.0.2 Flask-SocketIO==3.0.1

Flask-RESTful: Using GET to download a file with REST

故事扮演 提交于 2021-02-07 19:14:13
问题 I am trying to write a file sharing application that exposes a REST interface. The library I am using, Flask-RESTful only supports returning JSON by default. Obviously attempting to serve binary data over JSON is not a good idea at all. What is the most "RESTful" way of serving up binary data through a GET method? It appears possible to extend Flask-RESTful to support returning different data representations besides JSON but the documentation is scarce and I'm not sure if it's even the best

Flask-RESTful: Using GET to download a file with REST

时光总嘲笑我的痴心妄想 提交于 2021-02-07 19:12:37
问题 I am trying to write a file sharing application that exposes a REST interface. The library I am using, Flask-RESTful only supports returning JSON by default. Obviously attempting to serve binary data over JSON is not a good idea at all. What is the most "RESTful" way of serving up binary data through a GET method? It appears possible to extend Flask-RESTful to support returning different data representations besides JSON but the documentation is scarce and I'm not sure if it's even the best

Vue app doesn't load when served through Python Flask server

我是研究僧i 提交于 2021-02-07 19:11:05
问题 I have a simple "hello world" VueJS app I'm trying to get working: <!doctype html> <html> <head> <meta http-equiv="content-type" content="text/html; charset=utf-8" /> <script type="text/javascript" src="https://unpkg.com/vue"></script> </head> <body> <div id="app"> Message: {{ message }} </div> <script> var vm = new Vue({ el: "#app", data: { message: "Hello, world" } }); </script> </body> </html> When I load this file in the browser, off my local disk (ie: file:///home/user/vue-project/index

Vue app doesn't load when served through Python Flask server

﹥>﹥吖頭↗ 提交于 2021-02-07 19:10:01
问题 I have a simple "hello world" VueJS app I'm trying to get working: <!doctype html> <html> <head> <meta http-equiv="content-type" content="text/html; charset=utf-8" /> <script type="text/javascript" src="https://unpkg.com/vue"></script> </head> <body> <div id="app"> Message: {{ message }} </div> <script> var vm = new Vue({ el: "#app", data: { message: "Hello, world" } }); </script> </body> </html> When I load this file in the browser, off my local disk (ie: file:///home/user/vue-project/index

Vue app doesn't load when served through Python Flask server

南笙酒味 提交于 2021-02-07 19:05:26
问题 I have a simple "hello world" VueJS app I'm trying to get working: <!doctype html> <html> <head> <meta http-equiv="content-type" content="text/html; charset=utf-8" /> <script type="text/javascript" src="https://unpkg.com/vue"></script> </head> <body> <div id="app"> Message: {{ message }} </div> <script> var vm = new Vue({ el: "#app", data: { message: "Hello, world" } }); </script> </body> </html> When I load this file in the browser, off my local disk (ie: file:///home/user/vue-project/index

Flask, Python 3, error: “Additional arguments should be named”

落花浮王杯 提交于 2021-02-07 19:03:55
问题 Problem: i get an errorusig flask, and i am following a tutorial(using flash, i am a meh level python programmer(i get the basics)), so i don't understand why or what is wrong with this, so if you don't mind explaining it or adding a link to a place were it is explained... the error(i don't know what is important, sorry): C:\Users\name\Desktop\Eeverything on this computer\GCSE\Computer Science\free-style\organised\website>python flaskblog.py C:\Users\name\Anaconda3\lib\site-packages\flask

Flask, Python 3, error: “Additional arguments should be named”

孤人 提交于 2021-02-07 19:01:45
问题 Problem: i get an errorusig flask, and i am following a tutorial(using flash, i am a meh level python programmer(i get the basics)), so i don't understand why or what is wrong with this, so if you don't mind explaining it or adding a link to a place were it is explained... the error(i don't know what is important, sorry): C:\Users\name\Desktop\Eeverything on this computer\GCSE\Computer Science\free-style\organised\website>python flaskblog.py C:\Users\name\Anaconda3\lib\site-packages\flask

Alternative of send_file() in flask on Pythonanywhere?

余生颓废 提交于 2021-02-07 14:43:08
问题 I am new to python and still learning. I created a small python 3.6 Flask webapp on pythonanwhere and found out that send_file() is not working on pythonanywhere servers. I am actively looking for an alternative to download an excel file directly on the user machine. I also tried Response but it is not giving desired output. I read alot about it online and found that the send_file works fine if we set below wsgi-disable-file-wrapper = True However, i don't know where to set this as i couldn't

Importing from main app in a flask blueprint

只愿长相守 提交于 2021-02-07 14:20:02
问题 I'm writing an application with one blueprint. My application uses Flask-SQLAlchemy, so my blueprint needs access to the main app's db object (created by Flask-SQLAlchemy) in order to create its own models. However, when I try to get the db object with current_app.db , flask gives me the following error: RuntimeError: working outside of application context Here is my main __init__.py : from flask import Flask from app.uploader import uploader app = Flask(__name__) from flask.ext.sqlalchemy