Skip to main content

A web app framework to connect python projects to a simple but interactive frontend.

Project description

Wepps

A web app framework to connect python projects to a simple but interactive frontend.

Usage

The framework is build upon the idea of having different web apps inside a folder that can be addressed from the index page.

So, install the library using

pip install wepps

and copy the sample project from here.

If you want to start from scratch, create a python file that looks something like

from wepps import Site

if __name__ == "__main__":
    site = Site(apps_path="web_apps")
    site.run()

The apps_path is the name of the directory next to the python file. Also, next to the python file should be a README.md which will be used as the index page. Note that the path links inside there should be connected to the web apps structure, so if you have a subdirectory such as web_apps/complex/index.md, then use [complex](/complex) in markdown or [app](/interesting/thing) for web_apps/interesting/thing.py.

Inside of the apps_path, here web_apps should be an empty __init__.py to make it a python module and some directories which serve as topic directories for the web apps inside of it. In each of these directories should also be the obligatory __init__.py as well as an index.md file that displays information about the spefic topic. Each web app has a python and a markdown file with the same name; the markdown file serves as the documentation text for the specific web app.

One example web_apps structure might look like this:

├── main.py
├── README.md
└── web_apps
   ├── __init__.py
   └── demo
      ├── __init__.py
      ├── demo.md
      ├── demo.py
      └── index.md

The individual web apps (such as demo.py) should always have the basic following structure

from wepps.app import App, ResponseStages
import wepps.stage.stages as stages
from wepps.stage.parameters import PositiveInteger


d1_docs = stages.DocsStage("Title", "Some markdown/LaTeX documentation.")
s1_params = [PositiveInteger("xi", r"$\xi$", "Placeholdertext", r"Hover docs", False)]
s1_settings = stages.SettingsStage("unique_id", "Title", s1_params, False)
p1_plots = stages.PlotsStage("Title", "Some descriptive text.", None)

class Demo(App):
    def __init__(self) -> None:
        super().__init__(title="API Demonstration")

    def compute(self, response_data):
        r = ResponseStages()
        r.add_docs_stage(d1_docs)
        r.add_settings_stage(s1_settings)
        r.add_plot_stage(p1_plots)
        return r

All classes that inherit from the wepps.app.App will be displayed as individual web apps and linked at their folder position. So if the folder structure is web_apps/first/computation.py, the url of this app will be /first/computation.

For detailed information on what you can do and how you can react to changes, please have a look at this example.

Frontend Development

The frontend is built using Typescript and uses vite as a build tool. The backend uses by default the latest build of vite, i.e., the single Javascript file, if the enforce_dev_mode flag in web.py isn't set explicitly to True such as Site(..., enforce_dev_mode=True). To use the latest Typescript files (if anything was changed and wasn't build yet), one has to set the flag to True and start the vite development server.

For this cd into the src/frontend folder and enter

yarn
yarn dev

and start the backend from another project with the enforce_dev_mode=True flag . For this, the sample_project is probably a good start and can be altered to check the improvements etc.

Building

The project can be built inside the wepps/frontend folder with

yarn
yarn build

The files created this way will automatically be picked up by the frontend from the created src/wepps/static/manifest.json and are used by default. Currently, the build process doesn't delete old js files, so from time to time the files that aren't explicitly in the manifest.json file can be safely deleted.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

wepps-0.2.0.tar.gz (2.4 MB view details)

Uploaded Source

Built Distribution

wepps-0.2.0-py3-none-any.whl (2.4 MB view details)

Uploaded Python 3

File details

Details for the file wepps-0.2.0.tar.gz.

File metadata

  • Download URL: wepps-0.2.0.tar.gz
  • Upload date:
  • Size: 2.4 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.11.5

File hashes

Hashes for wepps-0.2.0.tar.gz
Algorithm Hash digest
SHA256 b12ff6d1a52932c697564a31e25bc420e2540694da4d94c9d1f92be9929be898
MD5 538c95e152c6480f36e55d1039de0661
BLAKE2b-256 77e3488b4fdce3db9b231ca46ef4f408c68e22e4c24b8825fe6bddc72d134550

See more details on using hashes here.

File details

Details for the file wepps-0.2.0-py3-none-any.whl.

File metadata

  • Download URL: wepps-0.2.0-py3-none-any.whl
  • Upload date:
  • Size: 2.4 MB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.11.5

File hashes

Hashes for wepps-0.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 64a8856057246d7b1d85b23a959af24599dc0ff3cdeb0b0702e06aea1b888906
MD5 46cdb20c1aa8a2d4a09ca1a9ef619e82
BLAKE2b-256 95c7e58857d79b1b12804e365c1eaf844b4820ef01fe5160224b0da57d721bec

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page