Package: wepps
WeppsA web app framework to connect python projects to a simple but interactive frontend.UsageThe 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 usingpipinstallweppsand copy the sample project fromhere.If you want to start from scratch, create a python file that looks something likefromweppsimportSiteif__name__=="__main__":site=Site(apps_path="web_apps")site.run()Theapps_pathis the name of the directory next to the python file.
Also, next to the python file should be aREADME.mdwhich 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 asweb_apps/complex/index.md, then use[complex](/complex)in markdown or[app](/interesting/thing)forweb_apps/interesting/thing.py.Inside of theapps_path, hereweb_appsshould be an empty__init__.pyto 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__.pyas well as anindex.mdfile 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 exampleweb_appsstructure might look like this:├── main.py
├── README.md
└── web_apps
   ├── __init__.py
   └── demo
      ├── __init__.py
      ├── demo.md
      ├── demo.py
      └── index.mdThe individual web apps (such asdemo.py) should always have the basic following structurefromwepps.appimportApp,ResponseStagesimportwepps.stage.stagesasstagesfromwepps.stage.parametersimportPositiveIntegerd1_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)classDemo(App):def__init__(self)->None:super().__init__(title="API Demonstration")defcompute(self,response_data):r=ResponseStages()r.add_docs_stage(d1_docs)r.add_settings_stage(s1_settings)r.add_plot_stage(p1_plots)returnrAll classes that inherit from thewepps.app.Appwill be displayed as individual web apps and linked at their folder position.
So if the folder structure isweb_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 atthis example.Frontend DevelopmentThe 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 theenforce_dev_modeflag inweb.pyisn't set explicitly toTruesuch asSite(..., 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 toTrueand start the vite development server.For this cd into thesrc/frontendfolder and enteryarn
yarndevand start the backend from another project with theenforce_dev_mode=Trueflag .
For this, thesample_projectis probably a good start and can be altered to check the improvements etc.BuildingThe project can be built inside thewepps/frontendfolder withyarn
yarnbuildThe files created this way will automatically be picked up by the frontend from the createdsrc/wepps/static/manifest.jsonand 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 themanifest.jsonfile can be safely deleted.