Loading
/custom-emojis/emojis/contour-map.png
Templates
📚
Articles & Resources
📖
Guides & Support
🌵
CalcTree
Estados de Vigas de Concreto
Bust Common Myths About Java Programming
Loading
/custom-emojis/emojis/calculator.png
Tensile Strength and Capacity Control of the W-Shape Sections According to AISC 360-16
Loading
/custom-emojis/emojis/calculator.png
Concrete Cylinder Strength Vs Cube Strength
Loading
/custom-emojis/emojis/calculator.png
Earthquake Design Action Calculation
Sıvılaşma Verileri Tablosu
Loading
/custom-emojis/emojis/rc-beam.png
Concrete Column Designer to AS3600
EM Wave Propagation Calculator
section properties with units
Forward Kinematics of Robotic Arm with 6 Degrees of Freedom
İKSA YAPILARI PROJELENDİRME HİZMET BEDELİ (2024)
GEOTEKNİK RAPOR (EK-B) ASGARİ HİZMET BEDELİ (2024)
ZEMİN İYİLEŞTİRME/DERİN TEMEL PROJELENDİRME ASGARİ HİZMET BEDELİ (2024) (İMO)
🚀
Projectile motion
Loading
/custom-emojis/emojis/bending-moment.png
Dezi et. al (2010)
🤾
Projectile motion
Transform Your Python Script into a Web App with CalcTree: A Step-by-Step Guide's banner
🖥️

Transform Your Python Script into a Web App with CalcTree: A Step-by-Step Guide

Engineers often rely on Python scripts to solve or verify the result of complex computational problems. However, sharing and collaborating on these scripts can be challenging, and they may not always be user-friendly because not everyone is good at coding. CalcTree offers a solution enabling you to convert your Python scripts into web applications, making them more accessible and shareable. This article will show you how to transform your Python script into a web app using CalcTree.

What is CalcTree

CalcTree, is a calculation management platform. You can sign-up and build hosted, shareable web apps (complete with an API and a web publishing module) with tools like Python and Spreadsheets. Learn more here!


Structuring Your Python Script for a Web App

Before converting your Python script into a web app, it's essential to structure the problem into inputs and outputs. This will help you understand how your app will receive input from the user, transfer the input to Python code for computation, and finally transfer the calculation output back to the page for the user.
Here's an example of how you might structure the input and output for a Python script that designs a baseplate according to EC3.
Page parameter input
ULS design load,


Steel strength,


Concrete strength,


Steel section properties e.g.


Page parameter output
Bearing capacity,


Required base plate width,


Required base plate width,


Required base plate thickness,




Now, let's explore the three basic steps to convert your Python script into a web app using CalcTree.

Step 1: Add Necessary Input Parameters to the Page Content

First, add the necessary input parameters to the page content. This will allow users to input the required data for your Python script to compute. Follow these steps:
  1. Type / on the page to receive the command menu
  2. Click on the Parameter field or press Enter to insert a parameter on the page. Change the default Untitled title of the parameter to an appropriate symbol.

Here's an example of what the input parameters might look like for the base plate design:

Inputs

Base plate



Ned
:20.0kN



fy
:275MPa


Concrete Support Properties



fck
:25MPa



acc
:0.85



yc
:1.50


Steel Column Properties



Section
:IPE - 500



h
:500mm


b
:200mm


r
:21.00


tw
:10.20mm


tf
:16mm


Perimeter
:1,744.00mm


Area
:11,552.00mm2


Step 2: Add Your Python Code

Next, add a Python source to your page. Follow these steps:
  1. Go to the Integrations panel on the right sidebar and click the "+ Add" button.
  2. Click the "Code" button to add your Python source.

  1. Write or paste your Python code inside the code editor, in the window at the bottom of your page.


Here's an example of what the code might look like for the base plate design:

👉 Note all the input page parameters are accessed by Python using "_page_" prefix, e.g. _page_b , _page_h, _page_tf. You can just type the name of your page parameter in the code editor, and a suggestion box will identify and allow you to select your parameters on the page.


Step 3: Add Calculated Python Parameters to Page Content

Your output parameters will appear on the right-hand side of your screen, in the page parameter list under Code source. To add these to your page, you can simply click and drag them to the page.
This will display the results of your Python code on the page for the user to see.

Here's an example of how you might arrange the output parameters for for the base plate design:

Outputs



fjd
:14.24MPa



Areq
:351,185mm2



c
:146mm



lp
:792mm



Wp
:492mm



tp
:58mm


Output parameters of a base plate with an I-section

Is the calculator valid, that is, do the T-stubs overlap?


check
:OK, there is no overlap between T-stubs.



👉 Note each output parameter is a block on the page, which can be grabbed and moved around the page, just like other page elements.

The app is ready to be published, see the live base plate designer in the link below:



Conclusion

CalcTree is a powerful platform that enables engineers to convert their Python scripts into user-friendly web applications. By following the three basic steps outlined in this article, you can transform your Python script into a web app, making it easier to share and collaborate with your colleagues.