简体   繁体   中英

Hosting Tornado server on Heroku

So I'm trying to host a python server on Heroku and I wasn't able to get it working, I have scaled to a basic hello world server for now just to get the errors out the way.

Initially, I was getting the error that Heroku could not allocate its own buildpack, so I manually added the python one, now the error is the python buildpack is not compatible with my app. Even though others have tornado working and it is pip installable

错误

I have a basic directory with the only 1 python file (.git folder hidden) 在此处输入图像描述

Here is the code for the server:

import tornado.ioloop
import tornado.web
import os
port = int(os.getenv('PORT', 8080))

class MainHandler(tornado.web.RequestHandler):
    def get(self):
        self.write("Hello, world")

def make_app():
    return tornado.web.Application([
        (r"/", MainHandler),
    ])

if __name__ == "__main__":
    app = make_app()
    app.listen(port)
    tornado.ioloop.IOLoop.current().start()

Any further clarifications/questions please let me know:) thanks

Figured out the problem, thought i'd leave it here for anyone else in the future

You need a "Procfile" and a "requirements.txt" for heroku to know what its running and what is needed to be installed.

在此处输入图像描述

Procfile:

web: python app.py

requirements.txt:

tornado==6.1

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM