#Not able to get app to host

104 messages · Page 1 of 1 (latest)

vivid wedge
#

port issue and crashes

silver pilot
#

remove the build and start commands

silver pilot
#

what framework is this btw

vivid wedge
silver pilot
#

okay, set the start command back, and set the PORT envvar on railway to whatever flask is listening on

unkempt python
#

Make sure flask is listening on 0.0.0.0 & not 127.0.0.1

vivid wedge
unkempt python
#

cool

#

set start command to gunicorn app:app & deploy

vivid wedge
#

when i started this post

#

^

unkempt python
vivid wedge
#

why does it ask if its listening on the right port

vivid wedge
unkempt python
#

what do you see there?

vivid wedge
#

init py file

vivid wedge
vivid wedge
chrome terrace
vivid wedge
chrome terrace
#

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.

vivid wedge
#

__init__.py

chrome terrace
#

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?

vivid wedge
chrome terrace
#

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

vivid wedge
#

changed the starting command

#

still doesnt work

chrome terrace
#

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

vivid wedge
#

i renamed it to app

#

gonna push it

chrome terrace
#

gunicorn app:app

vivid wedge
chrome terrace
#

deploy log again?

vivid wedge
vivid wedge
#

server just crashed

#

how does me not being able to import something say am i looking at the right port

chrome terrace
#

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__)?

chrome terrace
#

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

vivid wedge
chrome terrace
#

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

vivid wedge
#

app structure

#

what i get after changing all the commands, @chrome terrace

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

vivid wedge
#

what do u mean

#

gives me @app.route

vivid wedge
#

before this it was able to display the contents

#

now it cant because i changed it

chrome terrace
vivid wedge
chrome terrace
#

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

vivid wedge
#

what file is test_routes @chrome terrace

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.

vivid wedge
#

im confused on what you want me to do right now

#

you say they are unrelated but you want me to change the contents?

chrome terrace
#

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

vivid wedge
chrome terrace
#

just following the first screenshot should be enough

vivid wedge
chrome terrace
#

you only need to do one of these

vivid wedge
#

no module named routes

chrome terrace
#

what folder is routes in?

vivid wedge
chrome terrace
#

application/app.py
application/routes.py

vivid wedge
#

yes

chrome terrace
vivid wedge
#

cant even run the application now

chrome terrace
#

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

vivid wedge
#

correct?