How to debug FastAPI? #136
matt-grain
announced in
Q&A
Replies: 2 comments
-
Hmm I think this means an exception is being thrown somewhere within the Pynecone framework (any exception raised directly by your own defined event handlers should show up in the console). Could you share the relevant code maybe for the In the next version we will improve transparency and bubble up these errors, currently it is difficult to debug 😕 |
Beta Was this translation helpful? Give feedback.
0 replies
-
Yeah I finally understood what causes the problem (but not why). due to the refactoring, I have sub-sub-states and that is the issue: from typing import List, Dict
import pynecone as pc
class ButtonModel(pc.Model, table=False):
title: str
class AppState(pc.State):
"""The app state."""
default_field: str
class LocalState(AppState):
button_state: List[bool] = [False for i in range(10)]
@pc.var
def get_buttonmodel(self) -> List[ButtonModel]:
self.default_field = "break me"
return [ButtonModel(id=0, title="this is a button which breaks pynecone"), ButtonModel(id=1, title=self.default_field)]
class SubState(LocalState):
def trigger_fault(self) -> None:
print("error")
def index():
return pc.center(
pc.vstack(
pc.foreach(LocalState.get_buttonmodel, lambda a_model: display_form(a_model)),
spacing="1.5em",
font_size="2em",
),
padding_top="10%",
)
def display_form(model: ButtonModel):
return pc.button(model.title, size="lg", on_click=SubState.trigger_fault)
# Add state and page to the app.
app = pc.App(state=AppState)
app.add_page(index)
app.compile() |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Hi,
I started to refactor my code (according to the discussion on a multipages application), and I broke something. The
even
API returns a 500 but there is no trace in thepc.run
console.Only in the browser network tab:
Where is the
event
POST defined?Beta Was this translation helpful? Give feedback.
All reactions