Running a flask site on Yunohost?

My YunoHost server

Hardware: Old laptop
YunoHost version: 4.0.8
**I have access to my server : Physical access to machine, ssh, and web ui
Are you in a special context or did you perform some particular tweaking on your YunoHost instance ? : no

Description of my issue

I am trying to run my Python Flask website on Yunohost.
My first idea was to install the Flask_YNH app. https://github.com/YunoHost-Apps/flask_ynh. The package is marked as not working, and sure enough, it didn’t: https://paste.yunohost.org/raw/taqesanosa
(Even though I almost got it working in a VM)

My next idea was to find a better-maintained django app, and then just tinker until I got flask working. I found https://github.com/Jojo144/django_app_ynh. Tried installing it, but it couldn’t find the settings_ynh.py.example file, even though it was in my repo. https://paste.yunohost.org/raw/jumumagaha.scala

Now I’m kind of stuck. I suppose I could fork some existing flask app and just replace the actual Python with my own but I’m not really sure how I’d do that or what project would be a good, simple one to fork.

If anyone could point me in the right direction, I’d appreciate it!

You can have a look here. This is Django installation tutorial with web_app. You can try with Flash. If you get stuck, don’t hesitate to ask.

Well, I didn’t get very far. There seems to be some kind of problem setting up nginx or php-fpm. I’ve tried installing both my_webapp_ynh and multi_webapp_ynh.
Both installs fail with an error like this:

cp: cannot create regular file ‘/etc/nginx/conf.d/maindomain.tld.d/webapp_maindomain.tld_.conf’: No such file or directory

Install Logs:

I’m not sure how to debug this. Do you think a clean install would help?

You can not use maindomain.tld as your domain. Its not a valid domain. Use a registered domain from $Yunohost domain list. And use the my_webapp_ynh.

BTW: There has been update in the Flask package yesterday. You would like to try it again.

I know, it’s just a placeholder. I don’t want to publish my actual domain on the forum. The command and the error messages use my real domain name.

This is weird that /etc/nginx/conf.d/maindomain.tld.d do not exits.

2020-10-22 20:24:28,928: WARNING - cp: cannot create regular file '/etc/nginx/conf.d/maindomain.tld.d/my_webapp.conf': No such file or directory

Can you create it manually and try again?
$ mkdir -p /etc/nginx/conf.d/maindomain.tld.d

Worked! my_webapp_ynh is installed.
(Just create the directory. Why didn’t I think of that. :man_facepalming:)

Hopefully I’ll get my virtual environment and stuff set up tomorrow.
Thank you so much for your help. I’ll let you know if I run into any more problems.
Thanks again!

1 Like

It’s still not super-clean and everything but at least it installs (also had some weird stuff about ssowat conf but maybe it was just a typo on my side)

1 Like

Okay, I think I have everything up and running, however I’m running into a strange problem. my_webapp is running on maindomain.tld/flask. When I visit that route, it sends me a 302 redirect to maindomain.tld/yunohost/admin. What could be causing this?

Ideally, I’d like my_webapp to run on maindomain.tld/ and have the portal and admin page somewhere else. Is there a way to move the user interface and admin interface to say yunohost.maindomain.tld/ and prevent my_webapp from redirecting me?

No need to do this, you can define the app as the “default app” in the webadmin > Apps > my_webapp > find the default app button

Not sure but can you :

  • confirm you did not tweak the nginx conf manually ?
  • did you tweak the ssowat conf manually ?
  • otherwise let’s open the network tab in your browser (F12 → network, on firefox) and then try-again to go to the url and let’s see what happens exactly, wether you’re directly redirected to /yunohost/admin or if there are some intermediates urls
1 Like

I did tweak /etc/nginx/conf.d/domain_where_custom_web_app_installed.tld.d/my_webapp.conf like you mentioned on your “Django on Custom Webapp” post. I haven’t touched /etc/nginx/nginx.conf or anything like that.

Although, now that I look closer, I can’t see any of my changes in /etc/nginx/conf.d/domain_where_custom_web_app_installed.tld.d/my_webapp.conf anymore. I wonder if the webmin overwrote something…

When I visit the url, there is a 302 redirect to /yunohost/admin, then a 301 to /yunhost/admin/ which responds with 200, and starts loading stylesheets, javascript, etc.

This topic was automatically closed 15 days after the last reply. New replies are no longer allowed.