(Py)HP (H)ypertext (P)reprocessor
I want PHP style 'quick' template execution, but with Python instead.
Warning: Currently very insecure. Do not use.
Credit
I stole a lot of code from stackoverflow. Thanks to @aarondewindt for helping make this a reality.
Installation
PyHP is installable with pip
.
pip install pyhp-hypertext-preprocessor
You can then serve .pyhp
files fom your current directory with:
python -m pyhp.app
It is accessible at http://localhost:5000
. If you have an index.pyhp
file,
that will be served. If not, you'll have to explicitly go to http://localhost:5000/myfile.pyhp
to execute myfile.pyhp
. Static files with common extensions (like css, js, jpg, etc)
will automatically be served as static files.
Setup
You can set it up for local development with:
-
Fork this repository & clone your fork to your local machine.
-
Setup a virtual environment in your clone:
python3 -m venv venv source venv/bin/activate
-
Install the
pyhp
packagepip install -e .
-
Run
pyhp
!python3 -m pyhp.app
This should serve the contents of the current directory. You can try going to
http://localhost:5000/hi.pyhp
to test it out.