Aiohttp web sunucusunu heroku'ya dağıtın

Dec 21 2020

Heroku'ya gerçekten basit bir aiohttp uygulaması dağıtmaya çalışıyorum, işte main.pydosya:

import os
from aiohttp import web

routes = web.RouteTableDef()

@routes.get('/')
async def handle(request):
    return web.Response(text='Welcome')


app = web.Application()
app.add_routes(routes)

if __name__ == '__main__':
    port = int(os.environ['PORT'])
    web.run_app(app, port=port)

Ve işte Procfile

web: python main.py

Localhost'ta iyi çalışıyor, ancak onu heroku'ya yüklediğimde şunu alıyorum:

 heroku[router]: at=error code=H14 desc="No web processes running" method=GET path="/favicon.ico" host=******.herokuapp.com request_id=4e96418b-04bc-4bbb-bd4f-2b17320c3bc7 fwd="81.61.104.12" dyno= connect= service= status=503 bytes= protocol=https

Ayrıca, bu soru yardımcı olmadı.

Yanıtlar

DimaGavryshchyk Dec 22 2020 at 02:49

Burada bir satır yardımcı olmalı, şunu deneyin:

web.run_app(app, port=os.getenv('PORT'))

Onun yerine

if __name__ == '__main__':
    port = int(os.environ['PORT'])
    web.run_app(app, port=port)