R
Railway

✋|help

Flask app not working

Ppisquared28/21/2023
hey there am very new to railway, i would love to get some help, I am not familiar with hosting a website either. i would appreciate it if someone could walk me through setting it up, I've seen some youtube tutorials about hosting a flask app on railway but none of them worked for some reason.
Ppisquared28/21/2023
proejct id: b18dbcc6-1581-49d3-9f4b-7a0659942430
Jjonbeau8/21/2023
Hey, railway provides an env variable port. Could you ensure your app is listening on this, rather than 5000 or however it is currently configured?
Ppisquared28/21/2023
how can I do that
sorry but I've never hosted an app before
Jjonbeau8/21/2023
Can you share your repo?
Jjonbeau8/21/2023
Change like this

- app.run(debug=True)

+ import os
+ PORT = os.getenv('PORT')
+ app.run(host='0.0.0.0', port = PORT, debug=True)
Ppisquared28/21/2023
oh it worked
but now
i get this error after pressing one of the buttons
Ppisquared28/21/2023
Ppisquared28/21/2023
i think because tabula-py relies on java
Jjonbeau8/21/2023
I think here you need to add java as one of the build providers. If that doesn't work, someone smarter than me might have to help. 🙂
Ppisquared28/21/2023
ill try that :)
wait..
I dont have that option in settings
Ppisquared28/21/2023
Jjonbeau8/21/2023
Oh, you need to join priority boarding for that apparently. There's also a way to do it with config file I'm sure but I'm on my phone now and not the most familiar with it.
You can join that with /beta
Ppisquared28/21/2023
oh alright, thank you man, appreciate the help!! <3
hey there man 🤣
new day new error
Ppisquared28/21/2023
Jjonbeau8/21/2023
Did adding java in the profiders work? I think you can just add a nixpacks.toml file in your root with
providers = ['...', 'java']
or something like this
This looks like an error with your code. There is no year.
It should be like this:
Ppisquared28/21/2023
i added java in the providers
Jjonbeau8/21/2023
year = request.form.get('year')
if year:
your code
Ppisquared28/21/2023
now this is the error that it gives
how does it work perfectly fine on a local host then??
Ppisquared28/21/2023
Ppisquared28/21/2023
where do I add this text?
Jjonbeau8/21/2023
Are you sure you selected a year when you receive this error? if you use year = request.form['year'] and there is no year selected you will get an error. if you do something like:
year = request.form.get('year')
if year:
  print(year)
else:
  year = 2022
then it will set the year to 2022 if no year is selected, hope this helps
Ppisquared28/21/2023
it works perfectly fine in a local host
am pretty sure the problem is not with "year"
Jjonbeau8/21/2023
year = request.form['year'] will be a null value and you cant use it if year is not selected on the form
Jjonbeau8/21/2023
but im just using year as an example, it's the same for all the fields
I'm not sure why it works locally unless you had selected all the fields
Ppisquared28/21/2023
the website requests a pdf from a different website, does that have anything to do with it?
thats really weird
Jjonbeau8/21/2023
ill look at your code again shortly but you should put some error handling to flash a message to your user if they forgot to fill out the whole form https://flask.palletsprojects.com/en/2.3.x/patterns/flashing/
Ppisquared28/21/2023
alr man thanks!!
Jjonbeau8/21/2023
it shouldn't be an issue
in a railway.toml file in your root directory
https://nixpacks.com/docs/guides/configuring-builds

Looking for more? Join the community!

Recommended Posts
Average Cost of Ghost CMS Blog?Hi so I've recently moved over to Railway.app, after hearing great things about it and getting boggewebhook outdated docs and issuesHello First of, https://docs.railway.app/diagnose/webhooks this documentation seems outdated. I'm Configure GitHub PATHow do I configure my GitHub PAT (Personal Access token) while deploying my nestJS app on railway?How can I SSH into my CLI application?Hello, I have an CLI python app deployed but I need to connect to the service. I couldnt find how. IPostgres pricing questionsI'm starting to index a few data to my railway postgres. I need to clarify a few questions: 1. WhaDashboard: View cost by service is brokenI think postgres should be a new row?Memory not released even after postgres table droppedHello. Project ID: 6dee0732-68aa-4ae0-a472-7d02880e238a I created a table on 19th August and then Can only view 100 lines of logsI can only see the last 100 lines fo the logs in log viewer I have opted in to "priority boarding"Unexpected crash - Rust crashes after building with libgssapi-krb5 referenceHey, first time posting an error - my Railway deployment is crashing with the following error: erroDocker Service CRON Restart?Hi guys, i have a single docker service running. I'd like to restart this service periodically via tCan't set a private project to publicWhenever I try to set a private project to public, I get the error "All services in a public projectcan railway forward traffic to a self signed web application?i'm deploying an application and for some reason it needs to use self signed certificate, could railPrisma timeoutI am trying to use a fairly large query with Prisma and get `Timed out fetching a new connection frI want to run AirbyteI would like to use an ETL and I heard that Airbyte is good so I'm trying to set it up as a service NestJS application doesn't startHi, I'm trying to deploy a NestJS app but it gets stuck on a loop trying to start the server. I thiSQLite DatabaseIm trying to deplay a discord bot that uses an sqlite database. Ive created a persistent volume for About storageHello I'm newbie here, i just wanted to know how much storage will i have with the hobby plan?, I anode_modulesI'm trying to deploy using my build script. The build script consist in install normally the packageDefault Express template fails to deployHi, I've tried to deploy the ExpressJS template with no modifications, but am getting errors. Thx foQuestions about pricing for my customersHi, I'm planning to open a web agency and use Railway to deploy our customers' websites. Each custom