python:dev-mode
Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
python:dev-mode [2024/10/02 06:38] – kirtisingh | python:dev-mode [2024/10/02 07:52] (current) – kirtisingh | ||
---|---|---|---|
Line 77: | Line 77: | ||
< | < | ||
gunicorn -b 0.0.0.0: | gunicorn -b 0.0.0.0: | ||
+ | </ | ||
+ | |||
+ | To exit virtual environment use the command | ||
+ | < | ||
+ | deactivate | ||
</ | </ | ||
Line 91: | Line 96: | ||
< | < | ||
- | pip install | + | pip install |
pip install gunicorn | pip install gunicorn | ||
</ | </ | ||
- | You you can upload/ | + | Here we can refer to https://docs.djangoproject.com/en/5.1/intro/tutorial01/ to run a hello world Django application |
- | Below code is saved to hello.py | + | <code> |
+ | django-admin startproject mysite | ||
+ | cd mysite | ||
+ | </ | ||
+ | |||
+ | When you change into //mysite// folder, it contains //manage.py// along with a //mysite// child folder | ||
+ | |||
+ | W.r.t. Django, please refer to these important links \\ | ||
+ | * https:// | ||
+ | * https:// | ||
+ | |||
+ | Now to fire our Django app, we use gunicorn | ||
< | < | ||
- | from flask import Flask | + | gunicorn -b 0.0.0.0: |
+ | </ | ||
- | app = Flask(__name__) | + | To run it in background, we append & to the above command |
- | @app.route(" | + | < |
- | def hello_world(): | + | gunicorn -b 0.0.0.0:8000 -w 4 --forwarded-allow-ips=' |
- | | + | </code> |
+ | |||
+ | |||
+ | To exit virtual environment use the command | ||
+ | < | ||
+ | deactivate | ||
+ | </ | ||
+ | |||
+ | |||
+ | **Generic Python App** | ||
+ | |||
+ | < | ||
+ | mkdir generic-project | ||
+ | cd geneic-project | ||
+ | python3 -m venv .venv | ||
+ | source .venv/ | ||
+ | </ | ||
+ | |||
+ | Running the last command with activate the virtual environment, | ||
+ | |||
+ | < | ||
+ | pip install gunicorn | ||
+ | </ | ||
+ | |||
+ | Here is a small hello world example of our generic app | ||
+ | |||
+ | Below code is saved to hello.py | ||
+ | |||
+ | < | ||
+ | def app(environ, start_response): | ||
+ | | ||
+ | start_response(" | ||
+ | (" | ||
+ | (" | ||
+ | ]) | ||
+ | return iter([data]) | ||
</ | </ | ||
Line 117: | Line 169: | ||
To run it in background, we append & to the above command | To run it in background, we append & to the above command | ||
- | To exit virtual environment use the command | ||
< | < | ||
- | deactivate | + | gunicorn -b 0.0.0.0: |
</ | </ | ||
+ | To exit virtual environment use the command | ||
< | < | ||
- | gunicorn -b 0.0.0.0: | + | deactivate |
</ | </ | ||
+ | \\ | ||
+ | **With this our SSH Console aspect of our python project is covered. Now we will link our app to our VHost/ | ||
+ | |||
+ | |||
+ | **Step 6 :** Log into N99panel and click on ' | ||
+ | |||
+ | {{: | ||
+ | **Step 7 :** Now click on ' | ||
+ | {{: | ||
+ | **Step 8 :** Now further click on 'Map a Python Dev Port' | ||
+ | {{: | ||
+ | **Step 9 :** Fill the form with the requisite details | ||
+ | {{: | ||
+ | With these above mentioned steps, you can showcase your python apps to the world very easily. | ||
python/dev-mode.1727851101.txt.gz · Last modified: 2024/10/02 06:38 by kirtisingh