sandbox_python
Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
sandbox_python [2022/09/22 23:51] – [Python Web App] jhagstrand | sandbox_python [2023/01/12 04:58] (current) – removed jhagstrand | ||
---|---|---|---|
Line 1: | Line 1: | ||
- | ====== sandbox python ====== | ||
- | |||
- | ===== Python Scripts ===== | ||
- | |||
- | I can test my python script from the command line. \\ | ||
- | python index.cgi \\ | ||
- | |||
- | In the default a2hosting account, I can run any version of python. \\ | ||
- | python --version \\ | ||
- | python3 --version \\ | ||
- | python3.7 --version \\ | ||
- | |||
- | I can also create a virtual environment, | ||
- | Then I can use this environment to run cgi scripts. \\ | ||
- | |||
- | ===== Python Web App ===== | ||
- | |||
- | We already have python cgi available, as in index.cgi. | ||
- | But cgi is not an efficient way to run python. | ||
- | So now we will setup a more modern python implementation. \\ | ||
- | See a2hosting docs here. \\ | ||
- | [[http:// | ||
- | [[http:// | ||
- | |||
- | ==== Web Server Gateway Interface (WSGI) ==== | ||
- | |||
- | In cPanel, Setup Python App, Create Application. | ||
- | |||
- | Fill in the form thusly: | ||
- | |||
- | * Python version: | ||
- | * Application root: / | ||
- | * Application URL: sandbox.voyc.com/ | ||
- | * Application startup file: passenger_wsgi.py | ||
- | * Application Entry point: application | ||
- | * Passenger log file: / | ||
- | |||
- | Evidently this is Phusion Passenger. \\ | ||
- | From the URL we can call only one python function: the Entry Point in the Startup File. \\ | ||
- | Page navigation must be handled by the entry point function. \\ | ||
- | Presumably one could create multiple applications on one subdomain? \\ | ||
- | |||
- | The Application Root is similar to DocRoot. \\ | ||
- | The setup creates this folder and installs the startup file and three folders. \\ | ||
- | passenger_wsgi.py | ||
- | |||
- | This application can be stopped, restarted, and destroyed from the cPanel page. \\ | ||
- | I sometimes need to do a restart to make my program changes take effect. | ||
- | |||
- | ==== Virtual Environment ==== | ||
- | |||
- | The cPanel, Setup Python App, program already created a virtual environment for this app. | ||
- | Its location is / | ||
- | This folder contains bin/, lib/, and lib64 folders. | ||
- | To activate this enviroment offline. | ||
- | source / | ||
- | |||
- | Then I can install packages using Pip, and these packages are available to the web app as well. | ||
- | |||
- | ==== websockets ==== | ||
- | |||
sandbox_python.1663905074.txt.gz · Last modified: 2022/09/22 23:51 by jhagstrand