#Not able to get app to host
104 messages · Page 1 of 1 (latest)
remove the build and start commands
what framework is this btw
flask
okay, set the start command back, and set the PORT envvar on railway to whatever flask is listening on
Make sure flask is listening on 0.0.0.0 & not 127.0.0.1
port ennvar?
how do i do that
already did that
this is what i did
when i started this post
^
why does it crash?
im not sure
why does it ask if its listening on the right port
my run.py
when the server crashed
this file is named init.py?
init.py
then your gunicorn command would be gunicorn init:app but you also should use a more conventional name for the file. Either main.py or app.py. Will help prevent this in the future.
__init__.py
ah yeah it should not be in that file most likely. That is a python package management special file that is deprecated since python 3.6
is the tutorial you are following a bit old?
last year
they might know something I don't but my recommendation is to move the code into either app.py or main.py then whatever you chose pass to the gunicorn command
here is a minimal functional flask root file
then my associated gunicorn
if your file is called __init__ the name init wont work
since im not sure if you can pass __init__:app to guniconr that is why I am recommending changing the file
gunicorn app:app
deploy log again?
i need to import something?
server just crashed
how does me not being able to import something say am i looking at the right port
what is your project structure? You should have app.py at the top level of the project, not under any sub directories. Also is that the exact line of code you have written app = application(__name__)?
railway can't implement all the ways that everyones projects might break so it just makes an arbitrary guess
see this as a reference for why having your app in a subdirectory is non-default: https://stackoverflow.com/questions/16416172/how-can-i-modify-procfile-to-run-gunicorn-process-in-a-non-standard-folder-on-he
See my previous screenshots of an example minimal flask implementation for showing app = Flask(__name__), rather than app = application(__name__). Unless of course you have some auxiliary code that you havent shown
then what is my run.py file is supposed to contain?
some people like to split up their flask files a lot. Some don't split them up as much. Unless I see everything you have I can't answer that question. Maybe your project has separate init + run files? Maybe your problem would have been immediately resolved by writing gunicorn run:app? I don't know
my run.py
app structure
what i get after changing all the commands, @chrome terrace
thats good
that means the server is up and running now
all you need to do is define some routes
look for something in your tutorial that gives you @app.route and include that
this is on my local server
before this it was able to display the contents
now it cant because i changed it
https://stackoverflow.com/questions/11994325/how-to-divide-flask-app-into-multiple-py-files this is essentially what you are doing
You can use any of the solutions here. this might be the easiest for you from this moment
This is how i do it for my project
what file is test_routes @chrome terrace
your equivalent file is routes.py. This solution is suggesting that you use this import trick to expose the routes from routes.py to the main app.py file
notice though that your run.py and app.py are completely unrelated to one another. They make no references. So consider the possibility that changes in one of those files might not affect your overall app, since it's not being used.
im confused on what you want me to do right now
you say they are unrelated but you want me to change the contents?
test_routes.py = routes.py
I wanted to confirm that your unicorn command is gunicorn app:app because that means app.py = app.py also
yes here
just following the first screenshot should be enough
is this files switched?
what folder is routes in?
application
application/app.py
application/routes.py
hmm that should just work - https://stackoverflow.com/a/57058634
cant even run the application now
well yeah a broken import will stop application from running
im doing my best not having access to the files, but there is just a lot of nitty gritty stuff that needs to be done that is non-intuitive when you are setting up for the first time. So it's hard to debug remotely like this
correct?