相关疑难解决方法(0)

是否需要WSGI服务器和HTTP服务器来提供Flask应用程序?

使用uWSGI和Nginx设置Flask非常困难,即使使用buildout脚本也需要很长时间,并且必须将其记录到稍后要再现的指令中.

如果我不计划服务器上的大负载(它是公开的隐藏),没有uWSGI运行它是否有意义?(Flask可以收听端口.Nginx可以转发请求吗?)

甚至不使用Nginx,只是在端口上运行裸烧瓶应用程序是否有意义?

python nginx flask uwsgi

22
推荐指数
3
解决办法
1万
查看次数

在没有 nginx 的情况下运行 Flask 应用程序

在没有 nginx 或其他 Web 服务器的情况下运行 Flask 应用程序?

uWSGI 可以同时作为 Web 服务器和应用程序服务器吗?

例如,独立的 WSGI 容器 https://flask.palletsprojects.com/en/1.1.x/deploying/wsgi-standalone/ 但同样,它建议使用 HTTP 服务器。为什么?uWSGI 不能处理 HTTP 请求吗?

我阅读了有关部署 Flask 应用程序的不同文章。他们说,我需要 uWSGI 和 nginx——一种流行的选择。

https://www.digitalocean.com/community/tutorials/how-to-serve-flask-applications-with-uswgi-and-nginx-on-ubuntu-18-04

https://uwsgi-docs.readthedocs.io/en/latest/tutorials/Django_and_nginx.html

https://flask.palletsprojects.com/en/1.1.x/deploying/uwsgi/#uwsgi

我的烧瓶应用程序。app_service.py

import json
import os

from flask import Flask, Response, redirect


portToUse = 9401


@app.route("/app/people")
def get_service_people():
    print("Get people")
    people_str = "{ \"John\", \"Alex\" }"
    return Response(people_str, mimetype="application/json;charset=UTF-8")


if __name__ == "__main__":
    app.run(host='0.0.0.0', port=portToUse)
Run Code Online (Sandbox Code Playgroud)

uwsgi配置uwsgi.ini

[uwsgi]
chdir = $(APPDIR)
wsgi-file = app_service.py
callable = app
uid …
Run Code Online (Sandbox Code Playgroud)

nginx flask uwsgi python-3.x

5
推荐指数
1
解决办法
3911
查看次数

Python,Flask,'Hello World':没有浏览器反应

我在我的Window系统上安装了Flask和HTML5.当我用IDLE启动Hello World!-program时,我在Python-Shell中收到一条红色消息:

"* Running on xxxx://127.0.0.1:5000/". (xxxx = http)
Run Code Online (Sandbox Code Playgroud)

当我用app.run(debug = True)启动时,会出现另一条红色消息:

"* Restarting with reloader". 
Run Code Online (Sandbox Code Playgroud)

我的浏览器(Firefox)没有反应.如何在Firefox的新标签中获取"Hello World"?

守则是:

from flask import Flask
app = Flask(__name__)
@app.route("/")
def hello():
    return "Hello World!"
if __name__ == "__main__":
    app.run(debug=True)
Run Code Online (Sandbox Code Playgroud)

return和app.run是indended

python firefox flask

1
推荐指数
1
解决办法
1371
查看次数

标签 统计

flask ×3

nginx ×2

python ×2

uwsgi ×2

firefox ×1

python-3.x ×1