How to Deploy a Flask App to Linux (Apache and WSGI)

How to Deploy a Flask App to Linux (Apache and WSGI)

Luke Peters

3 года назад

56,112 Просмотров

Ссылки и html тэги не поддерживаются


Комментарии:

@LukePeters
@LukePeters - 18.05.2021 08:03

👋🏻 Hey! Do you like Python? Web app development? Automation?! Let me know what topics you'd like to see me cover next! 😃

Ответить
@TaylorNelson1
@TaylorNelson1 - 25.01.2024 00:18

Thanks for the video--why would I do this rather than use gunicorn?

Ответить
@jars99
@jars99 - 05.09.2023 01:04

I moved my virtualenv into /usr/local/venvs, and chowned the files to be owned by www-data:www-data because I was getting an error about permissions. Now I'm getting an internal server error, and the server log says "no such file" for index.html - any thoughts?

Ответить
@fahadshaikh9715
@fahadshaikh9715 - 18.08.2023 21:42

How to deploy multiple flask app on single server?

Ответить
@satisfyingsounds18
@satisfyingsounds18 - 08.08.2023 19:20

best

Ответить
@soolydooly1234
@soolydooly1234 - 22.07.2023 05:50

Hi, using old version of linux mint, but for every step I take something goes wrong... why would this be happening? For instance I get pkg_resources cannot be imported, when I've written "pip install setuptools" 100 times

Ответить
@user-br9sz4jn5k
@user-br9sz4jn5k - 04.07.2023 11:04

Wow, why did you delete my comments?
What is my wrong?
I am very grateful to you for the video...

Ответить
@justshoby3374
@justshoby3374 - 01.06.2023 03:55

Hey luke. Thanks for the video.
How did you chnage your terminal color? The colors looks very pleasing! Are you using iterm and omz? What is the theme? 😅

Ответить
@Quaght
@Quaght - 28.05.2023 22:18

This was awesome! I just built my very first flask app (actually my first web page) and wanted to try to deploy what I have next week for testing. Even without seeing the file structure of the server, I understood what you were explaining so I'm pretty confident. Thank you!

Ответить
@fahadshaikh9715
@fahadshaikh9715 - 12.05.2023 23:19

I got internal server error

Ответить
@fahadshaikh9715
@fahadshaikh9715 - 12.05.2023 07:07

Is it compulsory to make virtual env can we do same thing as root user?

Ответить
@XChristosK
@XChristosK - 10.05.2023 00:02

Hi, very good tutorial. Everything running fine.
I notice that if i change the home.html the content change only of i refresh apache.
can you provide a solution to that ?

I have already add
WSGIScriptReloading On
on virtual site but it didnt work.

Thanks

Ответить
@s.b.6683
@s.b.6683 - 29.03.2023 11:23

Thank you, this video helped fixing an error in my configuration!

Ответить
@krolik2531
@krolik2531 - 22.02.2023 17:00

Worked, thank you :)

Ответить
@GokEnsar
@GokEnsar - 04.02.2023 18:39

how can we set os.environ variables?

Ответить
@delvinnj7941
@delvinnj7941 - 03.02.2023 09:54

"Cannot access directory '/var/www/html/logs/' for error log of vhost defined at /etc/apache2/sites-enabled/basic-flask-app.conf:1"
I got this king for error while configtest Bro can you give a solution ???

Ответить
@deimos431
@deimos431 - 20.01.2023 01:20

Hello, thank you for this video, you saved me because I couldn't upload a server with my python flaskafter watching your tutorial.

Ответить
@enpassant7358
@enpassant7358 - 15.10.2022 20:04

👍The Perfect Tutorial! 👍 I am already comfortable with Apache and virtual domains and just needed a quick run through for hosting Python apps. The only thing that would make it better would be having a guthub repo with your project files. Excellent video, thank you.

Ответить
@TheAfmart
@TheAfmart - 13.09.2022 20:06

thank you, i need to migrate a flask app running on windows, and look like i need some extra steps

Ответить
@davipires2999
@davipires2999 - 10.09.2022 00:24

I’m havin this error message: AssertionError: You must use exec(open(this_file).read(), {'__file__': this_file}))

You know what that can be?

Ответить
@Turjak_art
@Turjak_art - 28.05.2022 00:41

Thank you. It is ridiculous what we need to do in order to solve such a simple task. Shame that in all those years of internet they never came to a better and simpler solution.

Ответить
@alialbaalbaki5801
@alialbaalbaki5801 - 17.05.2022 22:15

Thank u so much for the video. :)

Ответить
@caioathayde6498
@caioathayde6498 - 15.05.2022 04:36

Hey Luke, thanks for the great tutorial!
I've been able to deploy my website :))
I'm struggling with the error: app called on a post request cannot connect to X server. It runs perfectly on pycharm, but throws this error on the deployed version. I have changed the wsgi user,, exported the app to $PATH but no success. I read every related post on stackoverflow...
Would you give me a hint on that? Thanks

Ответить
@orco3847
@orco3847 - 13.05.2022 07:31

I almost wrote a comment "I love you for this incredible tutorial" but that would have been inappropriate...
Anyway, REALLY THANKS 🙏🏼 😀

Ответить
@utideptodeingenieriadeapli4293
@utideptodeingenieriadeapli4293 - 05.05.2022 17:25

hi, excelente video, but i have problems in deploy on debian 11 ... yu can help me ??? .. I do not receive any data in the request through post ...

Ответить
@parthpandey4631
@parthpandey4631 - 24.04.2022 11:09

I am not able to install pyvenv so I have used another way to install dependencies using pip install req.txt rather than using Pipfile.

Ответить
@jundihafizhul284
@jundihafizhul284 - 21.04.2022 13:57

Luke Peters, i want ask something, i we change the port in file basic-flask-app.conf (for example 4000) then we test in browser with ip:4000? is that correct?

Ответить
@bivensrk
@bivensrk - 18.04.2022 21:16

First ever time I thumbs up'd a vid.. outstanding tutorial, very detailed!

Ответить
@filippo1984
@filippo1984 - 11.04.2022 19:41

hi, nice tutorial very detailed, but i have a strange issue on the wsgi file, i can't understand what is wrong apparently the istrucions "with open(activate_this) as file_:
exec(file_.read(), dict(__file__=activate_this))" generate an error and i tried many solutions but non of them works

Ответить
@chad3328
@chad3328 - 09.04.2022 00:30

I just get a 404 no matter what. ugh

Ответить
@nikoklemm4709
@nikoklemm4709 - 26.03.2022 05:44

Hey, have you ever achieved to deploy a flask app with flask-socketio to a server and run it?

Ответить
@akarlska
@akarlska - 21.03.2022 17:10

Hey, great video. Gonna be super helpful! I´ve been using pyenv to manage virtual envs, is it possible to make this work with pyenv or is pipenv the only way? If possible, could you explain how? Because there is no activate.this file, only a .python_version file that lies in my flask_app folder.

Ответить
@schlingelgen
@schlingelgen - 21.03.2022 14:22

I am trying to run a Flask app on my raspberry with apache. Because this app sometimes needs GPIO-access, I can't run it without sudo. How can I tell apache to sudo run it? Or is there a better way?

I also run into some problems when accessing the machine with its hostname instead of the IP.
I then get the "Apache2 Debian Default Page" - unless I change line 4 in the .conf file.

With WSGIScriptAlias /{path} /var/www/basic-flask-app/app.wsgi the error doesn't occurs.
But then I have to call {hostname}.local/{path} instead of just {hostname}.local

Do you have any idea how to solve this? I am working with a Raspberry Pi Zero as I mentioned above

Thanks for the nice tutorial though!

Ответить
@sudeshkumar8377
@sudeshkumar8377 - 18.03.2022 12:56

I was able to install everything without any errors. I am facing some issue after starting the apache server and trying to access the server from chrome. Am getting two errors in the error log:
1] PermissionError: [Errno 13] Permission denied: '/root/.local/share/virtualenvs/OnlineLearner-uZdfk3kh/bin/activate_this.py'
2] Target WSGI script '/var/www/OnlineLearner/app.wsgi' cannot be loaded as Python module.

Please help me out Luke. Thanks in advance!!

Ответить
@vincenta2600
@vincenta2600 - 10.02.2022 20:29

Thank you so much, you helped me a lot with your video! :)

Ответить
@Richard_GIS
@Richard_GIS - 10.02.2022 01:48

The first useful tutorial at all for this usecase! Thy.

Ответить
@fobaytoos8915
@fobaytoos8915 - 02.02.2022 04:30

👍👍👍👍👌👌👌

Ответить
@patricktosolini6655
@patricktosolini6655 - 29.01.2022 20:43

Hi Luke that was an outstanding Tutorial!

Ответить
@Andyraathi
@Andyraathi - 31.12.2021 20:30

you are like a god to me

i appreciate your hardwork alot🤧🤧
stay posted like these videos💖💖

Ответить
@julienweems6166
@julienweems6166 - 31.12.2021 00:32

Thanks for the great tutorial! I know literally nothing about linux or apache and I still got it to work on my raspberry pi thanks to you

Ответить
@sulavadhikari5843
@sulavadhikari5843 - 06.12.2021 20:11

this makes me think machine learning is easier

Ответить
@adrianrs79
@adrianrs79 - 10.11.2021 13:18

what about if you have sqlalchemy, the way you illustrated the example can be applied to do so? thanks

Ответить
@joaovictor-dl6ve
@joaovictor-dl6ve - 30.09.2021 06:06

Whats the advantage to deploy a flask application with wsgi? Im new in flask…

Ответить