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:16] – kirtisingh | python:dev-mode [2024/10/02 07:52] (current) – kirtisingh | ||
---|---|---|---|
Line 53: | Line 53: | ||
</ | </ | ||
+ | You you can upload/ | ||
+ | Below code is saved to hello.py | ||
+ | < | ||
+ | from flask import Flask | ||
+ | app = Flask(__name__) | ||
+ | @app.route("/" | ||
+ | def hello_world(): | ||
+ | return "< | ||
+ | </ | ||
+ | Now to fire our flash app, we use gunicorn | ||
+ | < | ||
+ | gunicorn -b 0.0.0.0: | ||
+ | </ | ||
+ | To run it in background, we append & to the above command | ||
+ | |||
+ | < | ||
+ | gunicorn -b 0.0.0.0: | ||
+ | </ | ||
+ | |||
+ | To exit virtual environment use the command | ||
+ | < | ||
+ | deactivate | ||
+ | </ | ||
+ | |||
+ | **Django** | ||
+ | |||
+ | < | ||
+ | mkdir django-project | ||
+ | cd django-project | ||
+ | python3 -m venv .venv | ||
+ | source .venv/ | ||
+ | </ | ||
+ | |||
+ | Running the last command with activate the virtual environment, | ||
+ | |||
+ | < | ||
+ | pip install django | ||
+ | pip install gunicorn | ||
+ | </ | ||
+ | |||
+ | Here we can refer to https:// | ||
+ | |||
+ | < | ||
+ | django-admin startproject mysite | ||
+ | cd mysite | ||
+ | </ | ||
+ | |||
+ | When you change into //mysite// folder, it contains // | ||
+ | |||
+ | W.r.t. Django, please refer to these important links \\ | ||
+ | * https:// | ||
+ | * https:// | ||
+ | |||
+ | Now to fire our Django app, we use gunicorn | ||
+ | |||
+ | < | ||
+ | gunicorn -b 0.0.0.0: | ||
+ | </ | ||
+ | |||
+ | To run it in background, we append & to the above command | ||
+ | |||
+ | < | ||
+ | gunicorn -b 0.0.0.0: | ||
+ | </ | ||
+ | |||
+ | |||
+ | 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, | ||
+ | data = b" | ||
+ | start_response(" | ||
+ | (" | ||
+ | (" | ||
+ | ]) | ||
+ | return iter([data]) | ||
+ | </ | ||
+ | |||
+ | Now to fire our flash app, we use gunicorn | ||
+ | |||
+ | < | ||
+ | gunicorn -b 0.0.0.0: | ||
+ | </ | ||
+ | |||
+ | To run it in background, we append & to the above command | ||
+ | |||
+ | < | ||
+ | gunicorn -b 0.0.0.0: | ||
+ | </ | ||
+ | |||
+ | To exit virtual environment use the command | ||
+ | < | ||
+ | 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.1727849789.txt.gz · Last modified: 2024/10/02 06:16 by kirtisingh