Development Environment Installation
- Download and install python 3.1x
- Install VSCode
- Install vscode Extensions
Python : Microsoft
Create Virtual Dev Environment
- install virtualenv
windows: pip install virtualenv
osx: pip3 install virtualenv - Create the virtual enviroment
virtualenv env (env is the virtural enviroment name) - Activate the virtural enviroment
windows: env\scripts\activate
osx: source env/bin/activate
your prompt should now look like
(env) PS path…. windows: env\scripts\deactivate
osx: source env/bin/deactivate
Install App Development Requirements
osx: pip3 install mesop
windows: pip install mesop
Create a Basic Web App
create a file web1.py
add the folllowing
import mesop as me
@me.page(path=”/”)
def foo():
me.text(“This ia a basic page”)
Running The web app
Run the following in the terminal
mesop web1.py
Create a Multipage Web App with state
create a file web2.py
add the folllowing
import mesop as me
def on_click(e: me.ClickEvent):
state = me.state(State)
state.count += 1
me.navigate(“/multi_page_nav/page_2”)
@me.page(path=”/multi_page_nav”)
def main_page():
me.button(“Navigate to Page 2”, on_click=on_click)
@me.page(path=”/multi_page_nav/page_2″)
def page_2():
state = me.state(State)
me.text(f”Page 2 – count: {state.count}”)
@me.stateclass
class State:
count: int
Running The web app
Run the following in the terminal
mesop web2.py