A pythonic adaptation of React JS
Project description
PyReact
The goal of the repo is to introduce a pythonic web application tool similar to ReactJS. As you look through the code or build with PyReact you will notice similarities between the two; this is the point. You should be able to move between the two (PyReact & ReactJS) with ease and without the need to learn an entire new flow.
Release State: Alpha (Do not use for production)
Requirements
- Python 3.6+
- PyPM (pip install pypm2) - Refer to my repo PyPM for more information
Recommendations
- Please look at the PyPM repo. This tool is required to run PyReact and is similar to npm.
- If you're unfamiliar with ReactJS, head over to their site and get an overview of what it is.
- While PyReact is still in development, it is recommended to use this within a python virtual environment.
Installation
pip install pypm2
git clone https://github.com/ableinc/pyreact
cd pyreact
pypm install
pypm setup
How to run
pypm start
Create your own PyReact app
Note: It is recommended that you install PyReact in a python virtual environment.
- Make sure you follow the steps above to install PyReact
- Once installed, run
pyreact init
cd
into your new PyReact app directory- Run
pypm install
- All done!
File Structure
Notice, /app
is unrelated to the PyReact code. It is necessary to develop a PyReact web application, but is not tracked for release under the PyReact repo. Its here for testing purposes.
You will notice the start command in the package.json points to the index.py file in /app
. This is normal react convention. If you'd like to build your own PyReact application, please follow the installation instructions above and alter the contents of /app
. Do NOT edit within the /public
folder, as you could break your project.
Environment Variables
If you'd like your PyReact project to recognize new environment variables please prepend PYREACT_ to your variable names. Note, you will not need to import or install a library to import enviornment variables, PyReact does it under the hood. Just import variables with os.environ.
Examples
Just like this repo, examples and documentation are on-going. For the meantime, refer to the /app folder to see how everything works. Feel free to explore the pyreact code itself, if you notice something, make a PR!
Important Information
-
When you are creating your class views, containing your render function, make sure that
self.root(self)
is the first line in render. This flow is very important. In future updates this will not be needed. -
PyReact is both a client-side and server-side application. You have the full flexibility to do one or the other or both. Go to the
/examples
directory for examples.
Changelog
- Append user defined react class to index file to render - Done
- Add stylesheet rendering with html - Done
- Add or create a python syntax friendly way of generating views with HTML attributes (i.e. not using multiline strings to create view)
- Find and replace %PUBLIC_URL% in index.html - Done
- When user adds list of HTML elements to html content in render, it will be parsed appropriately - Done
- Fix recurssion error generated when setState() is used in either render() or init() - Done
- Be able to render multiple stylesheets for multiple pages - Done
- Add event listeners - Done
- Stop the browser from reopening the PyReact project homepage after every server refresh. - Disabled (Bug)
- Add Node dot notation dictionary/Object attribute
- When printing in view, display in browser console
- Create CLI tool to create PyReact app - Done
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file pyreact2-0.0.4.tar.gz
.
File metadata
- Download URL: pyreact2-0.0.4.tar.gz
- Upload date:
- Size: 11.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/1.13.0 pkginfo/1.5.0.1 requests/2.21.0 setuptools/50.3.0 requests-toolbelt/0.9.1 tqdm/4.32.1 CPython/3.6.8
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 34bfc977e0a12a46c471c002ad8ce728634a7725560b1719ddd6c08fdd7b3144 |
|
MD5 | c1dda39c3d834c619de42b9d1cf83479 |
|
BLAKE2b-256 | 3ae0c97261dd979ea41f0aadd4b6a5253a92623eceae19530b954805f696f75e |
File details
Details for the file pyreact2-0.0.4-py3-none-any.whl
.
File metadata
- Download URL: pyreact2-0.0.4-py3-none-any.whl
- Upload date:
- Size: 16.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/1.13.0 pkginfo/1.5.0.1 requests/2.21.0 setuptools/50.3.0 requests-toolbelt/0.9.1 tqdm/4.32.1 CPython/3.6.8
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | b80ac3bbc73e48add80637325e8f06209e643e1854fb0df1e175105c1fc36c83 |
|
MD5 | 38358a5885c39ebc2f759823ce9af88b |
|
BLAKE2b-256 | 20ed7ec10a256d65e831c15c0c9e607fc7bf8330632223a0ca7cdd1fdb598223 |