-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.py
More file actions
105 lines (88 loc) · 2.47 KB
/
main.py
File metadata and controls
105 lines (88 loc) · 2.47 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
from Perry import component, pageView, Composite, style
from Perry.Extra.bootstrap import bootstrap
from Perry.Extra.jquery import JQueryEngineStrapper
from Perry.Extra.pjec import PJECStrapper
import uvicorn
# Create our pages, we want them to inherit pageView behaviour.
# As well as other components
Homepage = component(pageView, _Inherit = True)
About = component(pageView, _Inherit = True)
LoginPage = component(pageView, _Inherit = True)
ourCustomStyle = style()
# Import contents for a pageView
from NexomiaApp import HomepageContents, LoginPageContents
# Custom style
ourCustomStyle <= {
'author':'Us',
'ctype':'css',
'css' : '''
* {
text-align: center;
margin: 0;
font-family: "Inter",sans-serif;
-webkit-font-smoothing: antialiased;
box-sizing: border-box;
--background-light: #4c5360;
--background-primary-alt: #404754;
--background-primary: #373d49;
--background-secondary-alt2: #363b47;
--background-secondary-alt: #333844;
--background-secondary: #2c313d;
--accent: #7794ce;
--accent-green: #52c96c;
--accent-yellow: #dcdd6e;
--accent-alt: #6d87bc;
--accent-dark: #4e5f82;
--text-primary: #dadfea;
--text-secondary: #68707f;
--text-negative: #ff3d70;
}
div {
display: block;
}
'''}
# Assign page contents
Homepage <= {
'title': 'Home',
'path':'',
'styles': [bootstrap, ourCustomStyle, PJECStrapper],
'DOM': pageView.DOM,
'components': HomepageContents
}
LoginPage <= {
'title': 'Login',
'path':'login',
'styles': [bootstrap, ourCustomStyle, PJECStrapper],
'DOM': pageView.DOM,
'components': LoginPageContents
}
About <= {
'title': 'About',
'path':'about',
'DOM': Homepage
}
Pages = Composite(Homepage, About, LoginPage)
# Multiple types of serving the pages are supported
#
'Flask'
# from PerryFlask import serve
# Serve our pages as a composite collection
# serve <= Pages
#
'FastAPI (Single page)'
from fastapi import FastAPI, Response
app = FastAPI()
# pages = Pages
# You can check all page info by printing the Composite component
# print(pages)
# You can also get page info by querying it's route,
# NOTE: The routes do not contain the initial '/'
# print(pages.get(''))
@app.get("/")
def read_root():
return Response(content=Pages.get('').run(), media_type="text/html")
@app.get("/login")
def read_login():
return Response(content=Pages.get('login').run(), media_type="text/html")
# Uvicorn for FastAPI
# uvicorn main:app --reload --host=0.0.0.0 --port=8080