Tag: flask

在远程主机上的Docker flask uwsgi 404

更新2 我configuration我的路由在从create_app调用的configure_blueprints。 我不想把所有的视图处理程序放在uwsgi.py中。 它们存储在单独的模块中。 def configure_blueprints(app): from .root import root_bp … blueprints = [ (root_bp, None), … ] for bp, endpoint in blueprints: app.register_blueprint(bp, url_prefix=endpoint) return app def create_app(config_fn=None): app = Flask(__name__, template_folder='../templates', static_folder='../static') … configure_blueprints(app) return app 应用程序/根/ views.py root_bp = Blueprint('root_bp', __name__) @root_bp.route('/') def root(): if not current_user.is_authenticated: return redirect('/login/') return render_template('index.html') 这里是SIMPLE_SETTINGS=app.config,instance.docker […]

如何在Docker容器中configurationFlask应用程序来parsing大型的MessagePack对象?

发送非常大的POST到Flask应用程序时,我得到以下内容。 日志: restful stderr | /usr/local/lib/python2.7/dist-packages/werkzeug/filesystem.py:63: BrokenFilesystemWarning: Detected a misconfigured UNIX filesystem: Will use UTF-8 as filesystem encoding instead of 'ANSI_X3.4-1968' BrokenFilesystemWarning) restful stderr | 172.19.0.5 – – [25/Apr/2017 00:05:40] "POST /ml/source/ HTTP/1.1" 500 – restful stderr | Traceback (most recent call last): File "/usr/local/lib/python2.7/dist-packages/flask/app.py", line 1836, in __call__ return self.wsgi_app(environ, start_response) File "/usr/local/lib/python2.7/dist-packages/flask/app.py", line […]

Flask应用程序不像unit testing那样从同一个数据库检索数据

我使用docker构build了一个应用程序,其中有三个容器。 一个托pipe后台数据库( db ),一个用于web api( app ),另一个用于运行自动化testing( test )。 这是描述三个容器之间链接docker-compose.yml的副本。 version: "3" services: app: build: context: ../ dockerfile: docker/app.Dockerfile environment: DB_NAME: ${PSQL_DATABASE} DB_USER: ${PSQL_USER} DB_PASSWORD: ${PSQL_PASSWORD} DB_PORT: ${PSQL_PORT} API_HOST: ${API_HOST} API_PORT: ${API_PORT} ports: – "5000:5000" depends_on: – db networks: – todo_backend tests: build: context: ../ dockerfile: docker/tests.Dockerfile environment: DB_NAME: ${PSQL_DATABASE} DB_USER: ${PSQL_USER} DB_PASSWORD: ${PSQL_PASSWORD} DB_PORT: […]

更新之后,不能在docker中运行瓶子中发出请求,但可以ping

我有一个瓶颈应用程序运行在docker上的nginx后面。 今天我遇到了一个非常奇怪的问题。 我通过sudo apt-get upgrade了我的系统(Ubuntu 16.04),我的笔记本电脑冻结了,我不得不手动重新启动它。 当我再次打开它,并通过撰写我的容器,突然,我正在工作的网站无法提出要求。 当我尝试这个: @root.route('/') def index(): r = requests.get('https://google.com') return "blah" 这给我一个错误。 URLError: <urlopen error [Errno 67] request timed out> 但是,这是完全正确的: @root.route('/') def index(): import os hostname = "google.com" #example response = os.system("ping -c 5 " + hostname) return str(response) 我没有改变任何代码。 在更新之前它正在运行100%。 我试图通过docker exec进入容器,并运行python我可以做的 requests.get('https://google.com') 并返回200响应。 我已经试图rm我的容器,并再次build立他们,但没有骰子。 我很迷茫,只是在寻找可能的线索。 我对networking了解不多。 任何帮助,将不胜感激。 […]

Visual Studio代码在将远程debugging附加到docker容器中的瓶颈应用程序期间卡住了

我目前正在从primefaces切换到Visual Studio代码 – 部分原因是debuggingfunction。 不幸的是我不能在以下设置中运行远程debugging : networking/ app.py from flask import Flask app = Flask(__name__) import ptvsd try: ptvsd.enable_attach(secret=None, address = ('0.0.0.0', 3000)) ptvsd.wait_for_attach() ptvsd.break_into_debugger() except: pass @app.route('/') def hello_world(): return 'Flask Dockerized' if __name__ == '__main__': app.run(debug=False,host='0.0.0.0', port=5000) 泊坞窗,compose.yml web: build: ./web ports: – "5000:5000" – "3000:3000" volumes: – .:/code launch.json { "name": "Attach […]

如何可靠地保持与我的Python Flask API打开的SSH隧道和MySQL连接?

我在Flask中构build了一个API,用Keras对文本信息进行分类。 我目前使用sshtunnel和MySQLdb连接到MySQL数据库以从远程数据库获取消息。 整个应用程序被封装在一个Docker容器中。 我能够build立到远程数据库的连接并成功查询它,但是每当POST请求进入API时,我都会打开和closures一个新的ssh隧道,这会降低性能。 我试图打开一个单独的ssh隧道和数据库连接来“统治所有”,但是如果在一个小时左右之后没有任何活动,连接就会过时,然后API请求将永远耗费一天的时间来完成。 你是怎么做到的? 这是缓慢的不可避免的还是有办法定期刷新SSH和数据库连接? 这是我连接到我的数据库为每个传入的请求: with SSHTunnelForwarder( (host, 22), ssh_username=ssh_username, ssh_private_key=ssh_private_key, remote_bind_address=(localhost, 3306) ) as server: conn = db.connect(host=localhost, port=server.local_bind_port, user=user, passwd=password, db=database)

为什么“pip install”不能在debian docker容器中使用Flask和gevent?

我正在试图用瓶子和geventbuild造一个docker集装箱,而且它并不像我所希望的那样工作。 我可以一起破解,但为什么不安装工作? 下面的全部细节。 Dockerfile: FROM debian:jessie 构build容器: docker build –pull –no-cache -t flask-test . 运行容器: docker run -it flask-test /bin/bash 在容器内: apt-get update apt-get -y install python-pip apt-get -y install python-dev pip install Flask gevent testing: python -c "from flask import Flask" 错误: root@2fe825b7f55e:/# python -c "from flask import Flask" Traceback (most recent call last): […]

docker运行找不到应用程序

我的项目结构是: /docker-test /app /static …. /templates …. -__init__.py …. -nginx.conf -supervisord.conf -uwsgi.ini -Dockerfile -app.py -requirements.txt 我通常通过进入/ docker-test> python app.py来运行应用程序 Dockerfile: FROM python:2.7 # Install uWSGI RUN pip install uwsgi # Standard set up Nginx ENV NGINX_VERSION 1.9.11-1~jessie RUN apt-key adv –keyserver hkp://pgp.mit.edu:80 –recv-keys 573BFD6B3D8FBC641079A6ABABF5BD827BD9BF62 \ && echo "deb http://nginx.org/packages/mainline/debian/ jessie nginx" >> /etc/apt/sources.list \ && […]

docker分割错误(core dump),在这种情况下该怎么办?

root@ramcharran-VirtualBox:/home/ramcharran/src# docker run -it dll_img /bin/bash bash-4.3# python3 app.py connection to cursor registering tokenizer virtual table created inserted data into virtual table Segmentation fault (core dumped) bash-4.3# 我已经尝试增加ulimit -c无限的核心限制,没有工作。 我已经在本地成功地执行了代码,但是用docker,我似乎得到了一个我不明白的分段错误。 我试图增加没有工作的basedevice存储。 我的docker机由于某种原因没有basedevice存储。 root@ramcharran-VirtualBox:/home/ramcharran# docker info Containers: 6 Running: 0 Paused: 0 Stopped: 6 Images: 19 Server Version: 1.12.3 **Storage Driver: aufs Root Dir: /var/lib/docker/aufs Backing […]

如何“dockerize”Flask应用程序?

我有Flask应用程序命名为rest.py,我有dockerize,但它没有运行。 #!flask/bin/python from flask import Flask, jsonify app = Flask(__name__) tasks = [ { 'id': 1, 'title': u'Buy groceries', 'description': u'Milk, Cheese, Pizza, Fruit, Tylenol', 'done': False } ] @app.route('/tasks', methods=['GET']) def get_tasks(): return jsonify({'tasks': tasks}) if __name__ == '__main__': app.run(debug=True) Dockerfile如下 FROM ubuntu RUN apt-get update -y RUN apt-get install -y python-dev python-pip COPY […]