-
Notifications
You must be signed in to change notification settings - Fork 0
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
0 parents
commit 4dc946f
Showing
9 changed files
with
197 additions
and
0 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 |
---|---|---|
@@ -0,0 +1,2 @@ | ||
# Auto detect text files and perform LF normalization | ||
* text=auto |
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,19 @@ | ||
[client] | ||
showErrorDetails = false | ||
toolbarMode = "viewer" | ||
|
||
[runner] | ||
magicEnabled = true | ||
|
||
[server] | ||
port = 8501 | ||
|
||
[browser] | ||
serverPort = 8501 | ||
|
||
[theme] | ||
base = "dark" | ||
primaryColor = "#a6d189" | ||
backgroundColor="#232634" | ||
secondaryBackgroundColor="#303446" | ||
textColor="#e78284" |
Empty file.
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,54 @@ | ||
# Streamlit Base | ||
|
||
## Intended Use | ||
|
||
### Gist | ||
|
||
This is a *template repository*, so its intended use is to create other repositories which **build off of this web app template**. | ||
|
||
### Use cases | ||
|
||
Set up by default with an **authentication system** - this is suited for general websites, but of course also works for data display apps. | ||
|
||
|
||
## Dependencies | ||
|
||
### Pip Packages | ||
|
||
All pip requirements are listed in *`requirements.txt`* | ||
|
||
|
||
## Authentication | ||
|
||
### Authentication Widgets | ||
|
||
Uses streamlit-authenticator library for authentication widgets | ||
|
||
### Credentials | ||
|
||
Credentials are stored in *`config.yaml`* | ||
|
||
|
||
## Config && Secrets | ||
|
||
### Config | ||
|
||
Configuration for Streamlit is stored in *`/.streamlit/config.toml`* | ||
|
||
### Secrets | ||
|
||
Secrets for Streamlit environment are stored in *`/.streamlit/secrets.toml`* | ||
|
||
|
||
## Github Actions | ||
|
||
### Pylint | ||
|
||
Default Pylint Github Action is set up in *`/.github/workflows/pylint.yml`* | ||
|
||
|
||
## Licensing | ||
|
||
### None (ish). | ||
|
||
Unlicensed using **`https://unlicense.org/`** - see *`UNLICENSE`* file |
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,24 @@ | ||
This is free and unencumbered software released into the public domain. | ||
|
||
Anyone is free to copy, modify, publish, use, compile, sell, or | ||
distribute this software, either in source code form or as a compiled | ||
binary, for any purpose, commercial or non-commercial, and by any | ||
means. | ||
|
||
In jurisdictions that recognize copyright laws, the author or authors | ||
of this software dedicate any and all copyright interest in the | ||
software to the public domain. We make this dedication for the benefit | ||
of the public at large and to the detriment of our heirs and | ||
successors. We intend this dedication to be an overt act of | ||
relinquishment in perpetuity of all present and future rights to this | ||
software under copyright law. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, | ||
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF | ||
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. | ||
IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR | ||
OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, | ||
ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR | ||
OTHER DEALINGS IN THE SOFTWARE. | ||
|
||
For more information, please refer to <http://unlicense.org/> |
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 @@ | ||
cookie: | ||
expiry_days: 0 | ||
key: credentials_key | ||
name: credentials | ||
credentials: | ||
usernames: | ||
example: # delete after first user is created | ||
email: [email protected] | ||
logged_in: false | ||
name: Example | ||
password: $bVAxa0JEenI1TkdGdnl2Uw$8qbxUe51emMU4d2VFeJivw | ||
preauthorized: | ||
emails: | ||
- [email protected] |
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,3 @@ | ||
streamlit | ||
extra-streamlit-components | ||
streamlit-authenticator |
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,57 @@ | ||
""" Main Streamlit site file """ | ||
|
||
from yaml.loader import SafeLoader | ||
import yaml | ||
|
||
import streamlit as st | ||
import streamlit_authenticator as stauth | ||
|
||
# Uncomment below if you need cookies: | ||
# import extra_streamlit_components as stx | ||
|
||
# Config page | ||
PAGE_TITLE = "" | ||
PAGE_ICON = "" | ||
st.set_page_config( | ||
PAGE_TITLE, PAGE_ICON, layout="wide", initial_sidebar_state="collapsed" | ||
) | ||
# | ||
|
||
# Checks for empty variables | ||
if not PAGE_TITLE: | ||
raise ValueError( | ||
"Please set the PAGE_TITLE variable to the title of your app") | ||
|
||
if not PAGE_ICON: | ||
raise ValueError( | ||
"Please set the PAGE_ICON variable to the icon of your app") | ||
# | ||
|
||
with open('config.yaml', 'r', encoding="utf-8") as file: | ||
config = yaml.load(file, Loader=SafeLoader) | ||
|
||
authenticator = stauth.Authenticate( | ||
config['credentials'], | ||
config['cookie']['name'], | ||
config['cookie']['key'], | ||
config['cookie']['expiry_days'], | ||
config['preauthorized'] | ||
) | ||
|
||
authenticator.login() | ||
|
||
auth_state = st.session_state["authentication_status"] | ||
if auth_state is False or auth_state is None: | ||
st.error('Username/password is incorrect') | ||
try: | ||
email, username, name = authenticator.register_user( | ||
preauthorization=False) | ||
if email: | ||
st.success('User registered successfully') | ||
with open('config.yaml', 'w', encoding="utf-8") as file: | ||
yaml.dump(config, file, default_flow_style=False) | ||
except Exception as e: | ||
st.error(e) | ||
else: | ||
# LOGGED IN CONTENT | ||
pass |
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,24 @@ | ||
name: Pylint | ||
|
||
on: [push] | ||
|
||
jobs: | ||
build: | ||
runs-on: ubuntu-latest | ||
strategy: | ||
matrix: | ||
python-version: ["3.12"] | ||
steps: | ||
- uses: actions/checkout@v3 | ||
- name: Set up Python ${{ matrix.python-version }} | ||
uses: actions/setup-python@v3 | ||
with: | ||
python-version: ${{ matrix.python-version }} | ||
- name: Install dependencies | ||
run: | | ||
python -m pip install --upgrade pip | ||
pip install pylint | ||
pip install -r requirements.txt | ||
- name: Analysing the code with pylint | ||
run: | | ||
pylint -d W0703 $(git ls-files '*.py') |