uWSGI和flask在本地运行,但不在浏览器中运行

时间:2019-06-17 10:09:45

标签: nginx flask uwsgi

我正在使用flask,uWSGI和nginx制作一个Web应用程序。但是,我的flask应用程序可以在localhost curl上运行,但不能在Web浏览器或邮递员中使用。

我尝试execute chown -R ubuntu:ubuntuchmod 777到我的文件夹中。但是,它不起作用。

以下是我的文件结构。

- app
    -- __init__.py  
.gitignore
requirements.txt 
app.ini  
run.py 

初始化 .py

import logging
import os

from flask import request, Flask
from flask_cors import CORS
from celery import Celery
from pymongo import MongoClient

from app.train import train
from app.respond import Response
from app.buildResponse import buildJson

import jpype
import uuid

logging.basicConfig(format='%(asctime)s,%(msecs)d %(levelname)-8s [%(filename)s:%(lineno)d] %(message)s',
                    datefmt='%d-%m-%Y:%H:%M:%S',
                    level=logging.DEBUG)

import datetime
# from threading import Thread

logging.basicConfig(format='%(asctime)s,%(msecs)d %(levelname)-8s [%(filename)s:%(lineno)d] %(message)s',
                    datefmt='%d-%m-%Y:%H:%M:%S',
                    level=logging.DEBUG)


utcnow = datetime.datetime.utcnow()
time_gap = datetime.timedelta(hours=9)
kor_time = utcnow + time_gap

mongo_address = "my-mongo-address"
client = MongoClient(mongo_address)

app = Flask(__name__)
cors = CORS(app)

@app.route("/", methods=["GET"])
def ping():
    try:
        return "Server is healthy"
    except Exception as e:
        logging.error(e)

run.py

from app import app

if __name__ == '__main__':
    app.run(host="0.0.0.0", use_reloader=False, debug=False, port=5000,
            ssl_context=("my-public-key",
                         "my-secret-key"))

app.ini

[uwsgi]
base=/home/ubuntu/myProject/app/
chdir=/home/ubuntu/myProject/
http=0.0.0.0:5000
callable=app
wsgi-file=run.py
socket=myproject.sock
chmod-socket=660
processes=4
threads=1
stats=0.0.0.0:9091
master=true
enable-threads=true
pidfile=/tmp/project-master.pid
die-on-term=true

它没有显示任何错误消息,但是我无法通过Web浏览器访问Web应用程序。

0 个答案:

没有答案