unit icon indicating copy to clipboard operation
unit copied to clipboard

DirectAdmin Nginx Unit for Python Applications

Open hosseinfani opened this issue 2 years ago • 3 comments

Hi there, I'm using nginx unit available in the "Advanced Feature" panel in DirectAdmin.

I created zzzz folder to host my python app inside the public_html folder like

/home/xxxx/domains/yyyy/public_html/zzzz/

and put the following sample python code and I make it readable and executable:

def application(environ, start_response):
    start_response("200 OK", [("Content-Type", "text/plain")])
    return (b"Hello, Python on Unit!")

I created an application: image

image

When I want to create a route: image

there is no template for python. Also, I have no idea what to put in the JSON part: image

And when I click on create, it raises this error: image

hosseinfani avatar Oct 03 '22 02:10 hosseinfani

Morning @hosseinfani thanks for reporting this. We need to talk to the people responsible for the admin tool. Looks like something is wrong here. Are you able to create a support ticket? Feel free to link my mail address t.stark[at]nginx[.]com

tippexs avatar Oct 03 '22 08:10 tippexs

@tippexs Thanks for your reply. How can I create a support ticket?

hosseinfani avatar Oct 03 '22 08:10 hosseinfani

As the AdminPanel itself is not our software I can not say how they did implement Unit under the hood. I have found this link.

https://tickets.directadmin.com/new_ticket.php

This should work for you. Let me know if you need any more help.

tippexs avatar Oct 03 '22 08:10 tippexs

Any update on this? I would like to get in touch with them to learn more about what they are doing with Unit.

tippexs avatar Dec 02 '22 20:12 tippexs

Hi @tippexs We could solve the issue by the help from our administrator and the test python app runs successfully. I will post the change we did for others info soon.

hosseinfani avatar Dec 04 '22 16:12 hosseinfani

Close due to inactivity. Please let us know if there is anything else we can do to help.

tippexs avatar Feb 18 '23 15:02 tippexs

Hi @tippexs We could solve the issue by the help from our administrator and the test python app runs successfully. I will post the change we did for others info soon.

@hosseinfani Could you please elaborate how you successfully installed your python/django app. I have the same issue !

maherchakroun avatar Apr 28 '23 17:04 maherchakroun

@maherchakroun 1- I shouldn't use the public_html in the path for the static content as it was a shortcut to another place in storage. I had to use the actual folder path of the webapp. Something like /home/yourwebapp

2- In the configuration, the home path should be the virtual environment that all the python packages are installed. Somthing like /home/yourwebapp/venv

3- Last, in the app.py (your driver code), I did the following changes:

< application = app
< @app.route("/neucg/", methods=["GET", "POST"])
---
> @app.route("/", methods=["GET", "POST"])

hosseinfani avatar Apr 28 '23 18:04 hosseinfani