This project has been archived by its maintainers, and is no longer receiving any updates.
Python PPHP: Hypertext Preprocessor.
PPHP
This is a spinoff of PHP (PHP: Hypertext Preprocessor) that uses Python instead of the PHP language.
How to use it:
To host the server, simply run python -m PPHPServer
To execute Python code inside a file, use:
<?pphp #code here (line breaks permitted) ?>
and output will be recorded in the same way as PHP - through stdout.
Example:
<p>Request method: <?pphp echo(_SERVER['REQUEST_METHOD']) ?></p>
Some special globals:
echo(text) - this is equivalent to sys.stdout.write(text)
escape(text) - this is equivalent to PHP’s htmlspecialchars - escapes special HTML characters.
__script__ - this is the entire script currently being executed
__db__ - this is the server’s database, more documentation below
_GET - this is the GET data as a dictionary
_POST - this is the POST data as a dictionary
_REQUEST - this is a combination of _GET and _POST
_SERVER - this is the equivalent of PHP’s $_SERVER, with some exceptions described below.
In _SERVER, the keys REQUEST_TIME, HTTP_ACCEPT, HTTP_ACCEPT_CHARSET, HTTP_HOST, HTTP_REFERER, HTTPS, REMOTE_HOST, SERVER_ADMIN, SERVER_SIGNATURE, SCRIPT_NAME, and SCRIPT_URI are all not available; and the key GATEWAY_INTERFACE returns the version of the cgi module, not the gateway interface.
Data for a server can be stored using the global __db__. This is simply a dictionary - you can store and retrieve values as such. Data in __db__ is stored as JSON in the file __DATABASE__.json, under ~/.pphp on Mac or Linux or %appdata%/.pphp on Windows. Changes to __db__ will only show up in __DATABASE__.json after all scripts have finished running. WARNING: Moving the file will reset that script’s data!
Thanks to:
banana439monkey for help in thinking of the name.
StackOverflow for help with the many problems I experienced.
Python (duh) for having such awesome batteries included.
Metadata
Release files for pphp 3.3.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| pphp-3.3.1.tar.gz | 6.1 kB | Without provenance | Details for pphp-3.3.1.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| pphp-3.3.1-py2.py3-none-any.whl | Python 2, Python 3 | none | any | Details for pphp-3.3.1-py2.py3-none-any.whl |
Total release size: 14.3 kB
Release files / pphp-3.3.1.tar.gz
| Download URL | pphp-3.3.1.tar.gz |
|---|---|
| Size | 6.1 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
7b4f2101938b34deebfc3d808900b77564ddcee8ab3a929ab01b492ac49ff414
|
|
BLAKE2b-256 checksum How to use checksums |
060413f5037af897eb861970128a9d8d4378464af72ea4de549e0b4d556fcdf7
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
Release files / pphp-3.3.1-py2.py3-none-any.whl
| Download URL | pphp-3.3.1-py2.py3-none-any.whl |
|---|---|
| Size | 8.3 kB |
| Tags | Python 2 Python 3 |
|
SHA-256 checksum How to use checksums |
5d3d5b8d05b4d1a149eb0bcef60853b26db8d6ee887e6d1fdbf9264ff30e8807
|
|
BLAKE2b-256 checksum How to use checksums |
d1189b49dc9413d4872d98bfeef82becd7da289a5a83fc3a47ecebaa30401bdc
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
Security for pphp 3.3.1
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.