gpt4 book ai didi

python - Flask/uWSGI/CentOS - 更新不起作用

转载 作者:太空宇宙 更新时间:2023-11-03 17:16:57 25 4
gpt4 key购买 nike

说实话,在服务器和维护方面我是菜鸟。

我完全按照以下指南创建了我的第一个“Hello There”页面,该页面目前已成功运行。

https://www.digitalocean.com/community/tutorials/how-to-serve-flask-applications-with-uwsgi-and-nginx-on-centos-7

但是在尝试通过向我的应用程序中插入更多代码并保存脚本来更新我的主页后,我浏览器中的服务器输出仍然保持相同的旧“你​​好”。

我更擅长函数式编程(数学)和数据库处理,但由于我必须为我的团队同事提供一些工具,所以我想到了一个快速主页。不幸的是,设置 python hp 比预期的要难。

先谢谢你斯特凡

编辑:我真的按照上面的链接 1 到 1。这是我的代码:

TAOWeb.py

from flask import Flask, render_template

application = Flask(__name__)

@application.route("/")
def hello():
return "<h style='color:green'> HELLO ASDF! </h1>"


if __name__ == "__main__":
application.run(host='0.0.0.0')

TAOWeb.ini

[uwsgi]
module = wsgi

master = true
processes = 5

socket = TAOWeb.sock
chmod-socket = 660
vacuum = true

die-on-term = true

wsgi.py

from TAOWeb import application

if __name__ == "__main__":
application.run()

/etc/systemd/system/TAOWeb.service

[Unit]
Description=uWSGI instance to serve TAOWeb
After=network.target

[Service]
User=tao
Group=nginx
WorkingDirectory=/home/tao/TAOWeb
Environment="PATH=/home/tao/TAOWeb/env/bin"
ExecStart=/home/tao/TAOWeb/env/bin/uwsgi --ini TAOWeb.ini

[Install]
WantedBy=multi-user.target

最后但同样重要的是 nginx 配置:

# For more information on configuration, see:
# * Official English Documentation: http://nginx.org/en/docs/
# * Official Russian Documentation: http://nginx.org/ru/docs/

user nginx;
worker_processes auto;
error_log /var/log/nginx/error.log;
pid /run/nginx.pid;

# Load dynamic modules. See /usr/share/nginx/README.dynamic.
include /usr/share/nginx/modules/*.conf;

events {
worker_connections 1024;
}

http {
log_format main '$remote_addr - $remote_user [$time_local] "$request" '
'$status $body_bytes_sent "$http_referer" '
'"$http_user_agent" "$http_x_forwarded_for"';

access_log /var/log/nginx/access.log main;

sendfile on;
tcp_nopush on;
tcp_nodelay on;
keepalive_timeout 65;
types_hash_max_size 2048;

include /etc/nginx/mime.types;
default_type application/octet-stream;

# Load modular configuration files from the /etc/nginx/conf.d directory.
# See http://nginx.org/en/docs/ngx_core_module.html#include
# for more information.
include /etc/nginx/conf.d/*.conf;

server {
listen 80;
server_name 185.164.5.211;

location / {
include uwsgi_params;
uwsgi_pass unix:/home/tao/TAOWeb/TAOWeb.sock;
}

}

server {
listen 80 default_server;
listen [::]:80 default_server;
server_name _;
root /usr/share/nginx/html;

# Load configuration files for the default server block.
include /etc/nginx/default.d/*.conf;

location / {
}

error_page 404 /404.html;
location = /40x.html {
}

error_page 500 502 503 504 /50x.html;
location = /50x.html {
}
}

# Settings for a TLS enabled server.
#
# server {
# listen 443 ssl http2 default_server;
# listen [::]:443 ssl http2 default_server;
# server_name _;
# root /usr/share/nginx/html;
#
# ssl_certificate "/etc/pki/nginx/server.crt";
# ssl_certificate_key "/etc/pki/nginx/private/server.key";
# ssl_session_cache shared:SSL:1m;
# ssl_session_timeout 10m;
# ssl_ciphers HIGH:!aNULL:!MD5;
# ssl_prefer_server_ciphers on;
#
# # Load configuration files for the default server block.
# include /etc/nginx/default.d/*.conf;
#
# location / {
# }
#
# error_page 404 /404.html;
# location = /40x.html {
# }
#
# error_page 500 502 503 504 /50x.html;
# location = /50x.html {
# }
# }

}

这是标准配置,只包含第一个服务器部分。

这有帮助吗?

最佳斯特凡

最佳答案

如果您确定您的代码是正确的并且正在使用谷歌浏览器,请尝试清除您的缓存

关于python - Flask/uWSGI/CentOS - 更新不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51294534/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com