Ask r/Flask Where to deploy a flask application ?
Hello,
I have a flask app + a script than runs with a crontab to populate data into a database.
I was wondering, is it better to deploy the app on a linux cloud server ? Or should I use a web hosting plateforms that supports flask out of the box ?
3
u/lebyath 7d ago
You could try playing around with an old computer. Install Ubuntu server on one you aren’t using and then set up a docker container. You could run everything g directly on Ubuntu too. But then you will have to deal with installing each dependency and what not.
Edit: I am sorry but this is sort of what I do. Just ignore me though, I’m probably not much help.
4
3
u/Content-Ad4644 6d ago
I deployed a flask web app for so suppliers can deliver bookings. It was deployed in Google cloud platform (GCP) , pay like 2 -3 bucks per month
1
2
2
2
u/beetroit 7d ago
Deploy for free on render or pay $5.5 on contabo.com
1
u/mattl1698 7d ago
do not use contabo, they are garbage, go with netcup or digitalocean or someone else reputable on r/VPS
2
u/sneakpeekbot 7d ago
Here's a sneak peek of /r/VPS using the top posts of the year!
#1: DO NOT USE CONTABO FOR ANYTHING IMPORTANT
#2: Do not use Contabo for anything important
#3: | 45 comments
I'm a bot, beep boop | Downvote to remove | Contact | Info | Opt-out | GitHub
2
u/beetroit 7d ago
Quite interestingly, i use contabo, and the only two issues i've ever had, were resolved via mail within 24hours (actually just a few hours), maybe i'm just lucky? But i still have 3 services running on contabo and no issues so far. Plus the links you tagged were from 9 months+ ago.
Not in any way siding with them, just saying they're not entirely as bad as the posts assumes. But then, OP is running a small app, and not a BaaS or something extreme which should work fine, especially for that price.
1
1
u/appliku 7d ago
Grab hetzner VPS, ARM ones if you can host in Europe (best performance and value for a euro)
And use Appliku to set everything up for you: https://appliku.com/post/how-deploy-flask-aws-ec2-hetzner-digital-ocean/
1
u/xlin0101 6d ago
I currently deploy my application on Azure App Service with a PostgreSQL database, using their basic tier plan. It costs me about $45 per month.
I‘m wondering if this is the most cost-effective solution.
1
u/Zamarok 6d ago
i don't know of any hosting providers that abstract flask app hosting. heroku Procfiles are probably the closest thing, but you can't access crontab on heroku. i would use hetzner, or aws with aws lambda for the flask app (i deploy flask app docker images with aws sam) and aws eventbridgescheduler for the conjob
1
u/Loopbloc 6d ago edited 6d ago
I am just using regular shared hosting for $40/year. Deployed 3 websites (node, flask, static), private email etc. The best for hobbyists.
1
u/EtherealSai 5d ago
A script that runs every once in a while is the perfect use case for serverless comptuing like AWS Lambda
1
u/ExplorerGT92 5d ago
It depends on what the application needs. I host/test simple flask/quart apps on a namecheap stellar plus shared hosting plan that was $36 for the first year. If the app uses SQL databases or user login/registration, I use Azure container app or app service.
1
u/joshuang2011 4d ago
Hiya!
I would recommend Vercel (vercel.com), I've hosted over 30 apps on it and has not charged me a single penny. It would require a bit of configuration to host flask apps, however it never takes you more than 2 minutes, create vercel.json then upload it to github (or other Git providers if you would like to) then boom, lightspeed app straight on the cloud, connect any subdomain or domain for free, a completely W to my life.
I can expand on if you want me to, I REALLY recommend it.
i've been trying to get reddit karma so I can post in certain subreddits.. please upvote IF you found it helpful. thanks!
1
u/Decent_Natural_8593 9h ago
Hola! Puedes ampliar tu respuesta de como lo hiciste, he estado intentando con Vercel pero me tira este error
This Serverless Function has crashed.
1
u/SuperPaard 3d ago
"Flask -> Gunicorn -> Nginx" is a solid and scalable setup for deploying a Flask application.
I highly recommend Digital Ocean's guide on this: https://www.digitalocean.com/community/tutorials/how-to-serve-flask-applications-with-gunicorn-and-nginx-on-ubuntu-22-04
As for hosting provider… You've got some solid advice already. Hetzner and Digital Ocean are both quite solid in my experience.
Happy deploying! ;)
1
u/mk_de Intermediate 6d ago
I hope it will help, this is what I am doing right now:
-Decouple your Flask app and script(main business logic).
1-Deploy your app to a VPS. I'd avoid such service providers like pythonanywhere. I had a problem with their billing system when trying to pay my subscription.
2-Rewrite your script in Rust and deploy it to AWS Lambda(There is free tier with up to 1M requests). Rust allows you to use less memory and compute time.
-(Possible t*ieves)Cloud services/(possible t*eacherous) sysadmins should not see/get your app and main business logic(your script) together under the guise of security audit.
-When rewriting your script with Rust, secure your strings with https://crates.io/crates/litcrypt or with https://dsxm.de/embed-str-asm/ (requires more skill). Do not let anyone get your strings with static analyzers or whatever.
Optional:
-Rewrite some of your python objects/functions that is being used in the app too with Rust by using pyo3 and installing them with maturin.
-For the peace of mind please do not use pip and instead use uv.
Best regards.
1
4
u/TheKiller36_real 7d ago
wasn't even aware there are providers for specifically Flask
you're more flexible with a "plain" cloud server so if it isn't tremendously more expensive that's what I would choose