Skip to content

Commit 79fe03c

Browse files
committed
Initial app bootstrapping with cookie cutter
Add pared down version of wsgi application from esp32 example to start
1 parent 492c4d9 commit 79fe03c

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

46 files changed

+15432
-2
lines changed

CODE_OF_CONDUCT.md

+127
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,127 @@
1+
# Adafruit Community Code of Conduct
2+
3+
## Our Pledge
4+
5+
In the interest of fostering an open and welcoming environment, we as
6+
contributors and leaders pledge to making participation in our project and
7+
our community a harassment-free experience for everyone, regardless of age, body
8+
size, disability, ethnicity, gender identity and expression, level or type of
9+
experience, education, socio-economic status, nationality, personal appearance,
10+
race, religion, or sexual identity and orientation.
11+
12+
## Our Standards
13+
14+
We are committed to providing a friendly, safe and welcoming environment for
15+
all.
16+
17+
Examples of behavior that contributes to creating a positive environment
18+
include:
19+
20+
* Be kind and courteous to others
21+
* Using welcoming and inclusive language
22+
* Being respectful of differing viewpoints and experiences
23+
* Collaborating with other community members
24+
* Gracefully accepting constructive criticism
25+
* Focusing on what is best for the community
26+
* Showing empathy towards other community members
27+
28+
Examples of unacceptable behavior by participants include:
29+
30+
* The use of sexualized language or imagery and sexual attention or advances
31+
* The use of inappropriate images, including in a community member's avatar
32+
* The use of inappropriate language, including in a community member's nickname
33+
* Any spamming, flaming, baiting or other attention-stealing behavior
34+
* Excessive or unwelcome helping; answering outside the scope of the question
35+
asked
36+
* Trolling, insulting/derogatory comments, and personal or political attacks
37+
* Public or private harassment
38+
* Publishing others' private information, such as a physical or electronic
39+
address, without explicit permission
40+
* Other conduct which could reasonably be considered inappropriate
41+
42+
The goal of the standards and moderation guidelines outlined here is to build
43+
and maintain a respectful community. We ask that you don’t just aim to be
44+
"technically unimpeachable", but rather try to be your best self.
45+
46+
We value many things beyond technical expertise, including collaboration and
47+
supporting others within our community. Providing a positive experience for
48+
other community members can have a much more significant impact than simply
49+
providing the correct answer.
50+
51+
## Our Responsibilities
52+
53+
Project leaders are responsible for clarifying the standards of acceptable
54+
behavior and are expected to take appropriate and fair corrective action in
55+
response to any instances of unacceptable behavior.
56+
57+
Project leaders have the right and responsibility to remove, edit, or
58+
reject messages, comments, commits, code, issues, and other contributions
59+
that are not aligned to this Code of Conduct, or to ban temporarily or
60+
permanently any community member for other behaviors that they deem
61+
inappropriate, threatening, offensive, or harmful.
62+
63+
## Moderation
64+
65+
Instances of behaviors that violate the Adafruit Community Code of Conduct
66+
may be reported by any member of the community. Community members are
67+
encouraged to report these situations, including situations they witness
68+
involving other community members.
69+
70+
You may report in the following ways:
71+
72+
In any situation, you may send an email to <[email protected]>.
73+
74+
On the Adafruit Discord, you may send an open message from any channel
75+
to all Community Helpers by tagging @community moderators. You may also send an
76+
open message from any channel, or a direct message to @kattni#1507,
77+
@tannewt#4653, @Dan Halbert#1614, @cater#2442, @sommersoft#0222, or
78+
@Andon#8175.
79+
80+
Email and direct message reports will be kept confidential.
81+
82+
In situations on Discord where the issue is particularly egregious, possibly
83+
illegal, requires immediate action, or violates the Discord terms of service,
84+
you should also report the message directly to Discord.
85+
86+
These are the steps for upholding our community’s standards of conduct.
87+
88+
1. Any member of the community may report any situation that violates the
89+
Adafruit Community Code of Conduct. All reports will be reviewed and
90+
investigated.
91+
2. If the behavior is an egregious violation, the community member who
92+
committed the violation may be banned immediately, without warning.
93+
3. Otherwise, moderators will first respond to such behavior with a warning.
94+
4. Moderators follow a soft "three strikes" policy - the community member may
95+
be given another chance, if they are receptive to the warning and change their
96+
behavior.
97+
5. If the community member is unreceptive or unreasonable when warned by a
98+
moderator, or the warning goes unheeded, they may be banned for a first or
99+
second offense. Repeated offenses will result in the community member being
100+
banned.
101+
102+
## Scope
103+
104+
This Code of Conduct and the enforcement policies listed above apply to all
105+
Adafruit Community venues. This includes but is not limited to any community
106+
spaces (both public and private), the entire Adafruit Discord server, and
107+
Adafruit GitHub repositories. Examples of Adafruit Community spaces include
108+
but are not limited to meet-ups, audio chats on the Adafruit Discord, or
109+
interaction at a conference.
110+
111+
This Code of Conduct applies both within project spaces and in public spaces
112+
when an individual is representing the project or its community. As a community
113+
member, you are representing our community, and are expected to behave
114+
accordingly.
115+
116+
## Attribution
117+
118+
This Code of Conduct is adapted from the [Contributor Covenant][homepage],
119+
version 1.4, available at
120+
<https://www.contributor-covenant.org/version/1/4/code-of-conduct.html>,
121+
and the [Rust Code of Conduct](https://www.rust-lang.org/en-US/conduct.html).
122+
123+
For other projects adopting the Adafruit Community Code of
124+
Conduct, please contact the maintainers of those projects for enforcement.
125+
If you wish to use this code of conduct for your own project, consider
126+
explicitly mentioning your moderation policy or making a copy with your
127+
own moderation policy so as to avoid confusion.

LICENSE

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
The MIT License (MIT)
2+
3+
Copyright (c) 2019 Matthew Costi for Adafruit Industries
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

README.md

-2
This file was deleted.

README.rst

+92
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,92 @@
1+
Introduction
2+
============
3+
4+
.. image:: https://readthedocs.org/projects/adafruit-circuitpython-wsgi/badge/?version=latest
5+
:target: https://circuitpython.readthedocs.io/projects/wsgi/en/latest/
6+
:alt: Documentation Status
7+
8+
.. image:: https://img.shields.io/discord/327254708534116352.svg
9+
:target: https://discord.gg/nBQh6qu
10+
:alt: Discord
11+
12+
.. image:: https://travis-ci.com/adafruit/Adafruit_CircuitPython_WSGI.svg?branch=master
13+
:target: https://travis-ci.com/adafruit/Adafruit_CircuitPython_WSGI
14+
:alt: Build Status
15+
16+
CircuitPython framework for creating WSGI compatible web server applications.
17+
18+
19+
Dependencies
20+
=============
21+
This driver depends on:
22+
23+
* `Adafruit CircuitPython <https://github.com/adafruit/circuitpython>`_
24+
25+
Please ensure all dependencies are available on the CircuitPython filesystem.
26+
This is easily achieved by downloading
27+
`the Adafruit library and driver bundle <https://github.com/adafruit/Adafruit_CircuitPython_Bundle>`_.
28+
29+
Installing from PyPI
30+
=====================
31+
.. note:: This library is not available on PyPI yet. Install documentation is included
32+
as a standard element. Stay tuned for PyPI availability!
33+
34+
.. todo:: Remove the above note if PyPI version is/will be available at time of release.
35+
If the library is not planned for PyPI, remove the entire 'Installing from PyPI' section.
36+
37+
On supported GNU/Linux systems like the Raspberry Pi, you can install the driver locally `from
38+
PyPI <https://pypi.org/project/adafruit-circuitpython-wsgi/>`_. To install for current user:
39+
40+
.. code-block:: shell
41+
42+
pip3 install adafruit-circuitpython-wsgi
43+
44+
To install system-wide (this may be required in some cases):
45+
46+
.. code-block:: shell
47+
48+
sudo pip3 install adafruit-circuitpython-wsgi
49+
50+
To install in a virtual environment in your current project:
51+
52+
.. code-block:: shell
53+
54+
mkdir project-name && cd project-name
55+
python3 -m venv .env
56+
source .env/bin/activate
57+
pip3 install adafruit-circuitpython-wsgi
58+
59+
Usage Example
60+
=============
61+
62+
.. todo:: Add a quick, simple example. It and other examples should live in the examples folder and be included in docs/examples.rst.
63+
64+
Contributing
65+
============
66+
67+
Contributions are welcome! Please read our `Code of Conduct
68+
<https://github.com/adafruit/Adafruit_CircuitPython_WSGI/blob/master/CODE_OF_CONDUCT.md>`_
69+
before contributing to help this project stay welcoming.
70+
71+
Sphinx documentation
72+
-----------------------
73+
74+
Sphinx is used to build the documentation based on rST files and comments in the code. First,
75+
install dependencies (feel free to reuse the virtual environment from above):
76+
77+
.. code-block:: shell
78+
79+
python3 -m venv .env
80+
source .env/bin/activate
81+
pip install Sphinx sphinx-rtd-theme
82+
83+
Now, once you have the virtual environment activated:
84+
85+
.. code-block:: shell
86+
87+
cd docs
88+
sphinx-build -E -W -b html . _build/html
89+
90+
This will output the documentation to ``docs/_build/html``. Open the index.html in your browser to
91+
view them. It will also (due to -W) error out on any warning like Travis will. This is a good way to
92+
locally verify it will pass.

adafruit_wsgi/wsgi_app.py

+102
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,102 @@
1+
# The MIT License (MIT)
2+
#
3+
# Copyright (c) 2019 Matthew Costi for Adafruit Industries
4+
#
5+
# Permission is hereby granted, free of charge, to any person obtaining a copy
6+
# of this software and associated documentation files (the "Software"), to deal
7+
# in the Software without restriction, including without limitation the rights
8+
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
# copies of the Software, and to permit persons to whom the Software is
10+
# furnished to do so, subject to the following conditions:
11+
#
12+
# The above copyright notice and this permission notice shall be included in
13+
# all copies or substantial portions of the Software.
14+
#
15+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21+
# THE SOFTWARE.
22+
"""
23+
`adafruit_wsgi`
24+
================================================================================
25+
26+
CircuitPython framework for creating WSGI server compatible web applications.
27+
This does *not* include server implementation, and must
28+
29+
30+
* Author(s): Matthew Costi
31+
32+
Implementation Notes
33+
--------------------
34+
35+
**Hardware:**
36+
37+
.. todo:: Add links to any specific hardware product page(s), or category page(s). Use unordered list & hyperlink rST
38+
inline format: "* `Link Text <url>`_"
39+
40+
**Software and Dependencies:**
41+
42+
* Adafruit CircuitPython firmware for the supported boards:
43+
https://github.com/adafruit/circuitpython/releases
44+
45+
.. todo:: Uncomment or remove the Bus Device and/or the Register library dependencies based on the library's use of either.
46+
47+
# * Adafruit's Bus Device library: https://github.com/adafruit/Adafruit_CircuitPython_BusDevice
48+
# * Adafruit's Register library: https://github.com/adafruit/Adafruit_CircuitPython_Register
49+
"""
50+
51+
# imports
52+
53+
__version__ = "0.0.0-auto.0"
54+
__repo__ = "https://github.com/adafruit/Adafruit_CircuitPython_WSGI.git"
55+
56+
class WSGIApp:
57+
"""
58+
TODO
59+
"""
60+
61+
def __init__(self):
62+
self._listeners = {}
63+
64+
def __call__(self, environ, start_response):
65+
"""
66+
Called whenever the server gets a request.
67+
The environ dict has details about the request per wsgi specification.
68+
Call start_response with the response status string and headers as a list of tuples.
69+
Return a single item list with the item being your response data string.
70+
"""
71+
72+
self._start_response = start_response
73+
status = ""
74+
headers = []
75+
resp_data = []
76+
77+
key = self._get_listener_key(environ["REQUEST_METHOD"].lower(), environ["PATH_INFO"])
78+
if key in self._listeners:
79+
status, headers, resp_data = self._listeners[key](environ)
80+
81+
self._start_response(status, headers)
82+
return resp_data
83+
84+
def on_request(self, method, path, request_handler):
85+
"""
86+
Register a Request Handler for a particular HTTP method and path.
87+
request_handler will be called whenever a matching HTTP request is received.
88+
89+
request_handler should accept the following args:
90+
(Dict environ)
91+
request_handler should return a tuple in the shape of:
92+
(status, header_list, data_iterable)
93+
94+
:param str method: the method of the HTTP request
95+
:param str path: the path of the HTTP request
96+
:param func request_handler: the function to call
97+
"""
98+
self._listeners[self._get_listener_key(method, path)] = request_handler
99+
100+
def _get_listener_key(self, method, path): # pylint: disable=no-self-use
101+
return "{0}|{1}".format(method.lower(), path)
102+

docs/_build/html/.buildinfo

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
# Sphinx build info version 1
2+
# This file hashes the configuration used when building these files. When it is not found, a full rebuild will be done.
3+
config: e238659d11b1f69af7ecff38526d4a39
4+
tags: 645f666f9bcd5a90fca523b33c5a78b7
3.2 KB
Binary file not shown.
1.5 MB
Binary file not shown.
2.91 KB
Binary file not shown.
19.9 KB
Binary file not shown.

docs/_build/html/_sources/api.rst.txt

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
2+
.. If you created a package, create one automodule per module in the package.
3+
4+
.. If your library file(s) are nested in a directory (e.g. /adafruit_foo/foo.py)
5+
.. use this format as the module name: "adafruit_foo.foo"
6+
7+
.. automodule:: adafruit_wsgi
8+
:members:
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
Simple test
2+
------------
3+
4+
Ensure your device works with this simple test.
5+
6+
.. literalinclude:: ../examples/wsgi_simpletest.py
7+
:caption: examples/wsgi_simpletest.py
8+
:linenos:

0 commit comments

Comments
 (0)