简体   繁体   English

尝试访问我的 Heroku 应用程序(Python/Flask)时出现“没有网络进程运行”错误

[英]"No web processes running" error when trying to reach my Heroku app (Python/Flask)

First time I created a very light python/flask application that is fully written in one file.我第一次创建了一个非常轻的 python/flask 应用程序,它完全写在一个文件中。 I tried to create a light API and make it accessible from the terminal (curl, etc.) and got the following error after I deployed it and tried to retrieve the data:我尝试创建一个轻量级 API 并使其可从终端(curl 等)访问,但在部署它并尝试检索数据后出现以下错误:

    desc="No web processes running" .....

The app folder structure:应用程序文件夹结构:

FolderName:文件夹名称:

app.py Procfile requirements.txt app.py Procfile requirements.txt

Now what each of them contains:现在他们每个人都包含:

app.py应用程序

    import flask
    import datetime
    import requests
    import json


    app = flask.Flask(__name__)


    @app.route('/covidData', methods=('GET', 'POST'))
    def get_data():

        country_input = flask.request.args.get('country')
        date_input = flask.request.args.get('date')
        date_split = date_input.split("-")
        date = datetime.datetime(int(date_split[2]),  int(date_split[0]), int(date_split[1])).strftime('%m-%d-%Y')

        data = requests.get('https://covid19.mathdro.id/api/daily/' + date)
        processed_data = data.json()

        for country in processed_data:
            if country['countryRegion'] == country_input:
                target_country = country

        requested_data = {"Country": target_country['countryRegion'], "Cases": target_country["confirmed"], "Recovered": target_country["recovered"]}

        return flask.jsonify(requested_data)


    if __name__ == '__main__':
        app.run(port=5000)

Procfile:简介:

    gunicorn wsgi:app

requirements:要求:

    requests==2.22.0
    Flask==1.1.1

How I deployed: 1. git init 2. heroku login 3. created a Procfile 4. heroku apps:create 5. git add .我是如何部署的: 1. git init 2. heroku login 3. 创建一个 Procfile 4. heroku apps:create 5. git add 。 6. git commit -m "heroku deployment" 7. git push heroku master 6. git commit -m "heroku deployment" 7. git push heroku master

Then, I try to retrieve the data from my local terminal:然后,我尝试从本地终端检索数据:

    curl -X POST "https://covid-19-2020-api.herokuapp.com/covidData?country=Israel&date=03-20-2020"

And get the following Error:并得到以下错误:

    heroku[router]: at=error code=H14 desc="No web processes running" method=POST path="/covidData?country=Israel&date=03-20-2020" host=covid-19-2020-api.herokuapp.com request_id=8b56257e-4c4f-46df-b8d9-ee487a4a5480 fwd="185.175.33.226" dyno= connect= service= status=503 bytes= protocol=https

What might be the problem, any advice, directions will be highly appreciated!可能是什么问题,任何建议,方向将不胜感激! I am newby in building APIs我是构建 API 的新手

Thank you!谢谢!

Ok, I found the solution.好的,我找到了解决方案。 It was done in three steps:它分三步完成:
1. in my terminal a ran heroku ps:scale web=1 - Getting Started on Heroku with Python 1. 在我的终端中运行heroku ps:scale web=1 - Getting Started on Heroku with Python
2. As I don't have a separate wsgi file, in my procfile, instead of wsgi, I put the name of the file gunicorn app:app 2. 由于我没有单独的 wsgi 文件,所以在我的 procfile 中,我输入了文件名gunicorn app:app ,而不是 wsgi
3. Added gunicorn to my requirements file 3.在我的需求文件中添加了gunicorn

Now the curl command works from any terminal现在 curl 命令可以从任何终端运行

The Procfile should look like this: Procfile 应如下所示:

web: <command>
web: gunicorn wsgi:app

reference example参考例子

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 heroku 中的错误 No web processes running python web app - error in heroku No web processes running python web app 如何修复'代码 = H14 desc =“没有 web 进程正在运行”' flask heroku 应用程序上的错误 - How to fix ' code=H14 desc=“No web processes running” ' error on flask heroku app H14 Heroku “没有 web 进程正在运行”,用于 Flask、ZA7F5F35426B9637411FC3Z23B1 - H14 Heroku “No web processes running” for Flask, Python 在Heroku上运行Flask应用时出现404错误 - 404 Error when running Flask app on Heroku 我试图在heroku上托管我的flask api,但是在将路径传递给我的应用程序时,出现导入错误 - im trying to host my flask api on heroku, but when passing the path to my app, i get an import error 在 Heroku 中启动我的 Python web 应用程序时出现应用程序错误 - Application Error when launching my Python web app in Heroku Heroku Flask 应用程序部署:持续的 H14 失败消息(无 Web 进程正在运行) - Heroku Flask App Deployment: Continuous H14 Failure Message (No Web Processes Running) 应用程序错误:我的 Flask-web-app 已成功部署在 Heroku 上,但在加载站点时收到应用程序错误 - Application error: My Flask-web-app is successfully deploy on Heroku but receiving application error when loading site 没有网络进程运行错误 - 在 Heroku 上部署 Django - No web processes running Error - Deploying Django on Heroku “没有 web 进程正在运行”Heroku 上的错误,部署 Fastapi - "No web processes running" Error on Heroku , Deploying Fastapi
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM