vendredi 19 novembre 2021

Problem while calling a function from python

i am doing a survey about pension. I was working in Anvil(free acount) but Facebook apps, see anvil.app as a treat so i purchase a Domain and made a web to host the app. The problem is that i used to call a function from jupyter to my anvil, and suddenly this stopped to work.

from ._anvil_designer import SaludoTemplate
from anvil import *
import anvil.tables as tables
import anvil.tables.query as q
from anvil.tables import app_tables
import anvil.server
import anvil.google.auth, anvil.google.drive
from anvil.google.drive import app_files
from random import sample

class Saludo(SaludoTemplate):
  
  
  
    
  def __init__(self, **properties):
    # Set Form properties and Data Bindings.
    self.init_components(**properties)
    lista = [1,2,3]
   def number(self, ): 
    intergers=sample(lista,k=1)
    string=[str(interger) for interger in intergers]
    a_string="".join(string)
    an_interger=int(a_string)
    return(an_interger)
    # Any code you write here will run when the form opens.
  def button_1_click(self, **event_args):
    num=anvil.server.call('number')
    for radio in self.column_panel_1.get_components():
      if radio.selected:
        q1_1=int(radio.value)
    respons=[99]*100
    respons[0]=num
    respons[1]=q1_1
    if respons[1]==1:
      open_form('Form2',respons)
    else:
      open_form('Final')

Also the code i used to run in Jupyter was

import anvil.server
anvil.server.connect("server_XXXXXXX")
from random import sample
lista = [1,2,3]
def number():
    intergers=sample(lista,k=1)
    string=[str(interger) for interger in intergers]
    a_string="".join(string)
    an_interger=int(a_string)
    return(an_interger)

Im not using free version, in case someone is wondering and the error i get back is

SyntaxError: unindent does not match any outer indentation level, just in def number




Aucun commentaire:

Enregistrer un commentaire