This is an automated email from the ASF dual-hosted git repository. gstein pushed a commit to branch trunk in repository https://gitbox.apache.org/repos/asf/steve.git
commit 3b90fe4296b9e2e84d3e51944592241e27334a5f Author: Greg Stein <[email protected]> AuthorDate: Mon Sep 1 05:58:48 2025 -0500 Initial skeleton for the webapp server. --- .gitignore | 2 ++ v3/server/api.py | 20 +++++++++++++++++ v3/server/config.yaml.example | 22 +++++++++++++++++++ v3/server/main.py | 50 +++++++++++++++++++++++++++++++++++++++++++ v3/server/pages.py | 31 +++++++++++++++++++++++++++ v3/server/templates/home.ezt | 20 +++++++++++++++++ 6 files changed, 145 insertions(+) diff --git a/.gitignore b/.gitignore index 2247ff4..86ebc43 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,6 @@ v3/bin/bs.zip +v3/server/config.yaml +v3/server/apptoken.txt ### default/generic ignores below diff --git a/v3/server/api.py b/v3/server/api.py new file mode 100644 index 0000000..174b581 --- /dev/null +++ b/v3/server/api.py @@ -0,0 +1,20 @@ +# +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright ownership. +# The ASF licenses this file to You under the Apache License, Version 2.0 +# (the "License"); you may not use this file except in compliance with +# the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +import asfquart +APP = asfquart.APP + diff --git a/v3/server/config.yaml.example b/v3/server/config.yaml.example new file mode 100644 index 0000000..b97c69d --- /dev/null +++ b/v3/server/config.yaml.example @@ -0,0 +1,22 @@ +# +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright ownership. +# The ASF licenses this file to You under the Apache License, Version 2.0 +# (the "License"); you may not use this file except in compliance with +# the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +# Default port for the server. Typical usage is that a proxy sits +# in front of this server, so we don't use ports 80 or 443. +# Note: we want 78383 which is "STEVE" on your telephone keypad. +# ... let's settle with something close (less than 65536). +port: 58383 diff --git a/v3/server/main.py b/v3/server/main.py old mode 100644 new mode 100755 index e69de29..0463ffc --- a/v3/server/main.py +++ b/v3/server/main.py @@ -0,0 +1,50 @@ +#!/usr/bin/env python3 +# +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright ownership. +# The ASF licenses this file to You under the Apache License, Version 2.0 +# (the "License"); you may not use this file except in compliance with +# the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +import logging +import pathlib + +import asfquart +from easydict import EasyDict as edict +import ezt + +_LOGGER = logging.getLogger(__name__) +DATE_FORMAT = '%m/%d %H:%M' + +THIS_DIR = pathlib.Path(__file__).resolve().parent + + +def main(): + logging.basicConfig(level=logging.DEBUG, + style='{', + format='[{asctime}|{levelname}|{module}] {message}', + datefmt=DATE_FORMAT, + ) + + app = asfquart.construct('steve') + + # Now that we have an APP, import modules that will add page + # and API endpoints into the APP. + import pages + import api + + app.runx(port=app.cfg.port) + + +if __name__ == '__main__': + main() diff --git a/v3/server/pages.py b/v3/server/pages.py new file mode 100644 index 0000000..d787185 --- /dev/null +++ b/v3/server/pages.py @@ -0,0 +1,31 @@ +# +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright ownership. +# The ASF licenses this file to You under the Apache License, Version 2.0 +# (the "License"); you may not use this file except in compliance with +# the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +import asfquart +APP = asfquart.APP + + [email protected]('/') [email protected]_template('templates/home.ezt') +async def home_page(): + return { } + + +# Route to serve static files (CSS and JS) [email protected]('/static/<path:filename>') +async def serve_static(filename): + return await send_from_directory('static', filename) diff --git a/v3/server/templates/home.ezt b/v3/server/templates/home.ezt new file mode 100644 index 0000000..b949a68 --- /dev/null +++ b/v3/server/templates/home.ezt @@ -0,0 +1,20 @@ +<!DOCTYPE html> +<html lang="en"> +<head> + <meta charset="UTF-8"> + <meta name="viewport" content="width=device-width, initial-scale=1.0"> + <title>Apache STeVe</title> + <!-- Bootstrap CSS --> + <link href="/static/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-4bw+/aepP/YC94hEpVNVgiZdgIC5+VKNBQNGCHeKRQN+PtmoHDEXuppvnDJzQIu9"> +</head> +<body> + <div class="container"> + <h1>Apache STeVe</h1> + <p>This is a basic example of a web page using Bootstrap.</p> + <button class="btn btn-primary">Click Me</button> + </div> + + <!-- Bootstrap JS (bundle includes Popper) --> + <script src="/static/js/bootstrap.bundle.min.js" integrity="sha384-HwwvtgBNo3bZJJLYd8oVXjrBZt8cqVSpeBNS5n7C8IVInixGAoxmnlMuBnhbgrkm"></script> +</body> +</html>
