r/flask 7d ago

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 ?

11 Upvotes

34 comments sorted by

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

1

u/Menxii 7d ago

I thought so too ... was thinking about a hetzner server for cheap ... setting up the flask app and nginx ...

But if i do so, how to monitor the app ?

2

u/beetroit 7d ago

Logfire, you can also use the logging module to stream logs to a file.

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

u/opshelp_com 7d ago

Just a VPS. Digitalocean, Linode etc..

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

u/Brilliant-Platypus16 3d ago

Which service are you using to deploy flask web apps to GCP? Thanks!

2

u/soliejordan 7d ago

1

u/ndcheezit 7d ago

I use this, it's been great

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:

Is this a Brute Force Attack?
| 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

u/dowcet 7d ago

What's better depends on... everything we don't know about your situation: what you're comfortable with managing yourself versus what you want to pay someone else to take care of, what level of reliability you need, etc.

1

u/catalystseyru 7d ago

Get a free ec2 instance on AWS, use guicorn to run it and nginx to proxy it

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/Menxii 6d ago

I saw that AMD servers have less RAM and are more expensive.

1

u/appliku 6d ago

ARM. Different architecture. Not amd

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/nickco7 6d ago

I've found the Oracle cloud free tier to be the best. Run it with gunicorn, nginx as the reverse proxy, and use cert bot. I had some flask apps running on Google and AWS but after the free tier ran out it got expensive to even run the smallest VM. Oracle allows 2 free VMs

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/evansap 6d ago

Check out Digital Ocean’s App platform with a managed DB or GCP Cloud Run

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/ejpusa 7d ago

DigitalOcean. It just works. Lot of options there. $8. If have issues just post.

https://www.digitalocean.com/community/tutorials/how-to-serve-flask-applications-with-gunicorn-and-nginx-on-ubuntu-20-04

1

u/someexgoogler 7d ago

I use the $5/ month droplets

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

u/Competitive-Fox2439 6d ago

Is rewriting things in rust worth it?

1

u/mk_de Intermediate 5d ago

For me, the sole purpose is obfuscation. If you've already secured your main logic by decoupling it from the app as explained above, the rest is optional.