-
-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
11 changed files
with
131 additions
and
211 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -16,3 +16,4 @@ backend/funix/build | |
*.db | ||
*.db-* | ||
logs.jsonl | ||
*.key |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
from funix import funix | ||
|
||
@funix( | ||
print_to_web=True | ||
) | ||
def foo() -> None: | ||
""" | ||
## What a great app in Funix! | ||
Funix won't let your docstring go to waste. | ||
""" | ||
print("It supports **Markdown**.") | ||
print ("And <b>HTML</b>.") | ||
return None |
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,46 +1,14 @@ | ||
from funix import funix, new_funix_type | ||
import ipywidgets | ||
|
||
|
||
@new_funix_type( | ||
widget={ | ||
"name": "password", | ||
"config": None | ||
} | ||
) | ||
# class NewPassword(ipywidgets.Password): | ||
class NewPassword(str): | ||
def check_safe(self) -> bool: | ||
if ( | ||
# len(self.value) > 6 | ||
# and any(char.isdigit() for char in self.value) | ||
# and any(char.isupper() for char in self.value) | ||
# and any(char.islower() for char in self.value) | ||
len(self) > 6 | ||
and any(char.isdigit() for char in self) | ||
and any(char.isupper() for char in self) | ||
and any(char.islower() for char in self) | ||
): | ||
return True | ||
return False | ||
|
||
|
||
@funix( | ||
title="New data type", | ||
description=""" | ||
# Defining your own data type and associating a widget with it | ||
In this example, using Python's native class definition syntax, we first define a new data type `NewPassword` inherited from the Python's standard `str` type. It has a member function `check_safe` which checks if the password is strong. | ||
Then, we use the `new_funix_type` decorator to associate the `NewPassword` type with the `password` widget. So a string of the `NewPassword` type will not be displayed as a normal string, but hidden when being entered. | ||
widget = {"name":"password", "config":None} | ||
) | ||
class blackout(str): | ||
def print(self): | ||
return self + " is the message." | ||
|
||
Now you can try it below. | ||
""", | ||
show_source=True, | ||
) | ||
def password_check(password: NewPassword="Freedom!1") -> str: | ||
safe_message = "Your password is strong." | ||
warning_message = "Your password is weak. It needs to contain at least 6 characters, including at least one digit, one upper case letter, and one lower case letter." | ||
def hoho(x: blackout = "Funix Rocks!") -> str: | ||
return x.print() | ||
|
||
return safe_message if password.check_safe() else warning_message | ||
if __name__ == "__main__": | ||
print (hoho(blackout('Fun'))) |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters