Commit
·
6c5d588
1
Parent(s):
b63fa99
fix socket
Browse files- app.py +1 -20
- demo_code_plugin/plugin.py +1 -1
- demo_code_plugin/templates/example.html +64 -1
- requirements.txt +1 -1
app.py
CHANGED
|
@@ -4,26 +4,7 @@ import os
|
|
| 4 |
if __name__ == "__main__":
|
| 5 |
import ivoryos
|
| 6 |
from ivoryos.config import DemoConfig
|
| 7 |
-
|
| 8 |
-
_conf = DemoConfig()
|
| 9 |
-
|
| 10 |
-
_conf.OUTPUT_FOLDER = '/tmp/ivoryos_data' # Just use absolute path directly
|
| 11 |
-
os.makedirs(_conf.OUTPUT_FOLDER, exist_ok=True)
|
| 12 |
-
|
| 13 |
-
_conf.CSV_FOLDER = os.path.join(_conf.OUTPUT_FOLDER, 'config_csv/')
|
| 14 |
-
_conf.SCRIPT_FOLDER = os.path.join(_conf.OUTPUT_FOLDER, 'scripts/')
|
| 15 |
-
_conf.DATA_FOLDER = os.path.join(_conf.OUTPUT_FOLDER, 'results/')
|
| 16 |
-
_conf.DUMMY_DECK = os.path.join(_conf.OUTPUT_FOLDER, 'pseudo_deck/')
|
| 17 |
-
_conf.LLM_OUTPUT = os.path.join(_conf.OUTPUT_FOLDER, 'llm_output/')
|
| 18 |
-
_conf.DECK_HISTORY = os.path.join(_conf.OUTPUT_FOLDER, 'deck_history.txt')
|
| 19 |
-
_conf.SQLALCHEMY_DATABASE_URI = f"sqlite:///{os.path.join(_conf.OUTPUT_FOLDER, 'ivoryos.db')}"
|
| 20 |
-
|
| 21 |
-
_conf.SESSION_COOKIE_SECURE = True
|
| 22 |
-
_conf.SESSION_COOKIE_SAMESITE = "None"
|
| 23 |
-
_conf.SESSION_COOKIE_HTTPONLY = True
|
| 24 |
-
|
| 25 |
-
_conf.SECRET_KEY = "demo-secret-key" # ✅ MUST HAVE THIS
|
| 26 |
-
ivoryos.run(__name__, config=_conf, blueprint_plugins=source_code, port=7860)
|
| 27 |
|
| 28 |
# # USE CASE 2 - start OS using current module and enable LLM with Ollama
|
| 29 |
# ivoryos.run(__name__, model="llama3.1", llm_server='localhost')
|
|
|
|
| 4 |
if __name__ == "__main__":
|
| 5 |
import ivoryos
|
| 6 |
from ivoryos.config import DemoConfig
|
| 7 |
+
ivoryos.run(__name__, config=DemoConfig(), blueprint_plugins=source_code, port=7860)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 8 |
|
| 9 |
# # USE CASE 2 - start OS using current module and enable LLM with Ollama
|
| 10 |
# ivoryos.run(__name__, model="llama3.1", llm_server='localhost')
|
demo_code_plugin/plugin.py
CHANGED
|
@@ -1,7 +1,7 @@
|
|
| 1 |
from flask import render_template, Blueprint, current_app
|
| 2 |
import os
|
| 3 |
|
| 4 |
-
source_code = Blueprint("
|
| 5 |
|
| 6 |
# # [main route] the route url can be anything, but "main" is needed as entry point
|
| 7 |
@source_code.route('/')
|
|
|
|
| 1 |
from flask import render_template, Blueprint, current_app
|
| 2 |
import os
|
| 3 |
|
| 4 |
+
source_code = Blueprint("About this demo", __name__, template_folder=os.path.join(os.path.dirname(__file__), "templates"))
|
| 5 |
|
| 6 |
# # [main route] the route url can be anything, but "main" is needed as entry point
|
| 7 |
@source_code.route('/')
|
demo_code_plugin/templates/example.html
CHANGED
|
@@ -1,6 +1,6 @@
|
|
| 1 |
{% if base_exists %}
|
| 2 |
{% extends 'base.html' %}
|
| 3 |
-
{% block title %}
|
| 4 |
{% else %}
|
| 5 |
<html lang="en">
|
| 6 |
<head>
|
|
@@ -15,7 +15,70 @@
|
|
| 15 |
|
| 16 |
|
| 17 |
{% block body %}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 18 |
<div class="container mt-4">
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 19 |
<h2>Source Code</h2>
|
| 20 |
<pre><code class="language-python">{{ code|e }}</code></pre>
|
| 21 |
</div>
|
|
|
|
| 1 |
{% if base_exists %}
|
| 2 |
{% extends 'base.html' %}
|
| 3 |
+
{% block title %}About this demo app{% endblock %}
|
| 4 |
{% else %}
|
| 5 |
<html lang="en">
|
| 6 |
<head>
|
|
|
|
| 15 |
|
| 16 |
|
| 17 |
{% block body %}
|
| 18 |
+
<style>
|
| 19 |
+
h2 {
|
| 20 |
+
color: #2c3e50;
|
| 21 |
+
border-bottom: 3px solid #3498db;
|
| 22 |
+
padding-bottom: 0.5rem;
|
| 23 |
+
margin-bottom: 1.5rem;
|
| 24 |
+
}
|
| 25 |
+
|
| 26 |
+
p {
|
| 27 |
+
margin-bottom: 1rem;
|
| 28 |
+
color: #555;
|
| 29 |
+
}
|
| 30 |
+
|
| 31 |
+
strong {
|
| 32 |
+
color: #2980b9;
|
| 33 |
+
}
|
| 34 |
+
|
| 35 |
+
code {
|
| 36 |
+
background: #f1f2f6;
|
| 37 |
+
padding: 0.2rem 0.4rem;
|
| 38 |
+
border-radius: 4px;
|
| 39 |
+
font-family: 'Consolas', 'Monaco', monospace;
|
| 40 |
+
color: #e74c3c;
|
| 41 |
+
font-size: 0.9em;
|
| 42 |
+
}
|
| 43 |
+
|
| 44 |
+
pre {
|
| 45 |
+
background: #2c3e50;
|
| 46 |
+
color: #ecf0f1;
|
| 47 |
+
padding: 1.5rem;
|
| 48 |
+
border-radius: 8px;
|
| 49 |
+
overflow-x: auto;
|
| 50 |
+
margin: 1rem 0;
|
| 51 |
+
border-left: 4px solid #3498db;
|
| 52 |
+
}
|
| 53 |
+
|
| 54 |
+
pre code {
|
| 55 |
+
background: none;
|
| 56 |
+
color: #ecf0f1;
|
| 57 |
+
padding: 0;
|
| 58 |
+
border-radius: 0;
|
| 59 |
+
font-size: 0.9rem;
|
| 60 |
+
}
|
| 61 |
+
|
| 62 |
+
.highlight {
|
| 63 |
+
background: linear-gradient(120deg, #a8edea 0%, #fed6e3 100%);
|
| 64 |
+
padding: 0.1rem 0.3rem;
|
| 65 |
+
border-radius: 3px;
|
| 66 |
+
}
|
| 67 |
+
</style>
|
| 68 |
<div class="container mt-4">
|
| 69 |
+
<h2>IvoryOS Demo</h2>
|
| 70 |
+
|
| 71 |
+
<p>
|
| 72 |
+
<strong>IvoryOS</strong> dynamically inspects functions from any Python script, rendering them as draggable method cards in the browser.
|
| 73 |
+
</p>
|
| 74 |
+
<p>
|
| 75 |
+
The source code below is the source script used to build this demo.
|
| 76 |
+
Three instances "pump", "balance" and "sdl" are created in this script, and can be either called in <strong>Device</strong> tab, or used to build a workflow in <strong>Design</strong> tab.
|
| 77 |
+
</p>
|
| 78 |
+
<p>
|
| 79 |
+
For authentication, user passwords are securely hashed using <code>bcrypt</code> before being stored.
|
| 80 |
+
Use this demo to explore IvoryOS features!
|
| 81 |
+
</p>
|
| 82 |
<h2>Source Code</h2>
|
| 83 |
<pre><code class="language-python">{{ code|e }}</code></pre>
|
| 84 |
</div>
|
requirements.txt
CHANGED
|
@@ -1 +1 @@
|
|
| 1 |
-
ivoryos>=1.0.
|
|
|
|
| 1 |
+
ivoryos>=1.0.7
|