1

I'm trying to deploy a really simple aiohttp app to heroku, here's main.py file:

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)

And here's the Procfile

web: python main.py

It works fine in localhost, but when I upload it to heroku I get:

 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

Also, this question didn't help.

1 Answers1

0

One line should help here, just try:

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

Instead of

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