onlinewebdirectory-site 1.0.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- onlinewebdirectory_site-1.0.0/LICENSE +21 -0
- onlinewebdirectory_site-1.0.0/PKG-INFO +248 -0
- onlinewebdirectory_site-1.0.0/README.md +228 -0
- onlinewebdirectory_site-1.0.0/onlinewebdirectory_site/__init__.py +19 -0
- onlinewebdirectory_site-1.0.0/onlinewebdirectory_site/__main__.py +5 -0
- onlinewebdirectory_site-1.0.0/onlinewebdirectory_site/badge.py +46 -0
- onlinewebdirectory_site-1.0.0/onlinewebdirectory_site/cli.py +238 -0
- onlinewebdirectory_site-1.0.0/onlinewebdirectory_site/client.py +197 -0
- onlinewebdirectory_site-1.0.0/onlinewebdirectory_site/files.py +54 -0
- onlinewebdirectory_site-1.0.0/onlinewebdirectory_site/middleware.py +67 -0
- onlinewebdirectory_site-1.0.0/onlinewebdirectory_site/site.py +175 -0
- onlinewebdirectory_site-1.0.0/onlinewebdirectory_site/store.py +57 -0
- onlinewebdirectory_site-1.0.0/onlinewebdirectory_site/visits.py +127 -0
- onlinewebdirectory_site-1.0.0/onlinewebdirectory_site.egg-info/PKG-INFO +248 -0
- onlinewebdirectory_site-1.0.0/onlinewebdirectory_site.egg-info/SOURCES.txt +18 -0
- onlinewebdirectory_site-1.0.0/onlinewebdirectory_site.egg-info/dependency_links.txt +1 -0
- onlinewebdirectory_site-1.0.0/onlinewebdirectory_site.egg-info/entry_points.txt +2 -0
- onlinewebdirectory_site-1.0.0/onlinewebdirectory_site.egg-info/top_level.txt +1 -0
- onlinewebdirectory_site-1.0.0/pyproject.toml +32 -0
- onlinewebdirectory_site-1.0.0/setup.cfg +4 -0
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Online Web Directory
|
|
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.
|
|
@@ -0,0 +1,248 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: onlinewebdirectory_site
|
|
3
|
+
Version: 1.0.0
|
|
4
|
+
Summary: Connect a Python site to Online Web Directory: see whether AI agents can get in, confirm your free listing, and count the AI agents that request your pages.
|
|
5
|
+
Author: Online Web Directory
|
|
6
|
+
License: MIT
|
|
7
|
+
Project-URL: Homepage, https://onlinewebdirectory.net/
|
|
8
|
+
Project-URL: Documentation, https://onlinewebdirectory.net/integrations/django
|
|
9
|
+
Project-URL: Source, https://github.com/onlinewebdirectory/site-integrations/tree/main/python
|
|
10
|
+
Project-URL: Blog, https://onlinewebdirectory.net/blog/
|
|
11
|
+
Keywords: ai agents,llms.txt,robots.txt,directory,wsgi,asgi
|
|
12
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
13
|
+
Classifier: Programming Language :: Python :: 3
|
|
14
|
+
Classifier: Programming Language :: Python :: 3.9
|
|
15
|
+
Classifier: Operating System :: OS Independent
|
|
16
|
+
Requires-Python: >=3.9
|
|
17
|
+
Description-Content-Type: text/markdown
|
|
18
|
+
License-File: LICENSE
|
|
19
|
+
Dynamic: license-file
|
|
20
|
+
|
|
21
|
+
# Online Web Directory for Python sites
|
|
22
|
+
|
|
23
|
+
[](https://github.com/onlinewebdirectory/site-integrations)
|
|
24
|
+
|
|
25
|
+
### ⭐ [Star this repo on GitHub](https://github.com/onlinewebdirectory/site-integrations)
|
|
26
|
+
|
|
27
|
+
One click. It is how other people with the same problem find this.
|
|
28
|
+
|
|
29
|
+
[](https://onlinewebdirectory.net)
|
|
30
|
+
|
|
31
|
+
**[Website](https://onlinewebdirectory.net)** · [Check your site, free](https://onlinewebdirectory.net/check) · [Confirm your listing, free](https://onlinewebdirectory.net/confirm) · [Pricing](https://onlinewebdirectory.net/pricing) · [Blog](https://onlinewebdirectory.net/blog/) · [Moltbook](https://www.moltbook.com/u/onlinewebdirectory) · [m/agentweb](https://www.moltbook.com/m/agentweb) · [The Colony](https://thecolony.cc/u/onlinewebdirectory)
|
|
32
|
+
|
|
33
|
+
[](https://www.npmjs.com/package/onlinewebdirectory-site) [](https://rubygems.org/gems/onlinewebdirectory-site) [](https://packagist.org/packages/onlinewebdirectory/site) [](https://github.com/onlinewebdirectory/site-integrations/blob/main/LICENSE)
|
|
34
|
+
|
|
35
|
+
See whether AI agents can get into your site, confirm your free directory listing, and count the AI agents that request your pages.
|
|
36
|
+
|
|
37
|
+
Online Web Directory is where AI agents look a website up before they fetch it. This package connects a site built on Django, Flask, FastAPI or any other WSGI or ASGI framework to the directory.
|
|
38
|
+
|
|
39
|
+
It uses the Python standard library only. Python 3.9 or newer.
|
|
40
|
+
|
|
41
|
+
## Free
|
|
42
|
+
|
|
43
|
+
- Pass or fail: can an AI agent with a plain web client get into your site? Plus a readiness score out of 100 and the date it was checked.
|
|
44
|
+
- Confirm your free listing from the command line, with no email round trip. Tell agents what your site is, in your own words.
|
|
45
|
+
- A count of requests from AI agents and crawlers (GPTBot, ClaudeBot, PerplexityBot and others), counted on your own server.
|
|
46
|
+
- A directory badge you can place in a template. It is never shown unless you place it.
|
|
47
|
+
|
|
48
|
+
## Paid, bought from the command line
|
|
49
|
+
|
|
50
|
+
- Monitor: which agents came, which pages they asked for and the count for each day. A daily check, and an email when the result changes. You can ask for a fresh look after you change your site with `recheck`.
|
|
51
|
+
- Fix report: every point behind your score, what was found, why it matters and how to fix it. Where this package can help with the fix (robots.txt lines for AI bots, an llms.txt made from your pages) the report says so.
|
|
52
|
+
|
|
53
|
+
Prices come from the service and are shown by `status` before you pay. Payment is by card on a secure payment page.
|
|
54
|
+
|
|
55
|
+
## Install
|
|
56
|
+
|
|
57
|
+
```
|
|
58
|
+
pip install onlinewebdirectory_site
|
|
59
|
+
```
|
|
60
|
+
|
|
61
|
+
## Connect your site
|
|
62
|
+
|
|
63
|
+
Run these where your site's code lives. Replace YOUR-DOMAIN with your site's address.
|
|
64
|
+
|
|
65
|
+
```
|
|
66
|
+
python -m onlinewebdirectory_site connect YOUR-DOMAIN
|
|
67
|
+
```
|
|
68
|
+
|
|
69
|
+
This saves a proof and its secret in `.owd-site.json` and prints one line, `OWD_SITE_PROOF=...`. If your site runs somewhere else, set that line in its environment and deploy. The middleware then answers `/.well-known/owd-site.txt` with the proof. The proof works for one hour.
|
|
70
|
+
|
|
71
|
+
```
|
|
72
|
+
python -m onlinewebdirectory_site verify
|
|
73
|
+
```
|
|
74
|
+
|
|
75
|
+
The service reads the proof file once and gives you a key. `verify` prints `OWD_SITE_KEY=...` one time: set it in the environment where your site runs. It also saves the key in `.owd-site.json` and removes the proof and secret from it. You can then remove `OWD_SITE_PROOF`. Do not run `verify` in a loop: the service rations it.
|
|
76
|
+
|
|
77
|
+
The proof file has to open at the top of your domain. A site that lives in a sub-folder cannot connect yet.
|
|
78
|
+
|
|
79
|
+
### Keep `.owd-site.json` private
|
|
80
|
+
|
|
81
|
+
The file is made with mode 0600. It holds your key. Add it to `.gitignore` and never put it in version control. Set `OWD_SITE_FILE` to keep it somewhere else.
|
|
82
|
+
|
|
83
|
+
## Settings
|
|
84
|
+
|
|
85
|
+
| Environment | What it is |
|
|
86
|
+
| --- | --- |
|
|
87
|
+
| `OWD_SITE_KEY` | Your site key. When it is not set, the key is read from `.owd-site.json`. |
|
|
88
|
+
| `OWD_SITE_PROOF` | The proof to serve while you connect. When it is not set, the proof is read from `.owd-site.json`. |
|
|
89
|
+
| `OWD_SITE_FILE` | Where `.owd-site.json` is kept. Default: the folder the process starts in. |
|
|
90
|
+
| `OWD_API` | The service address. Default: `https://onlinewebdirectory.net`. |
|
|
91
|
+
|
|
92
|
+
## Add the middleware
|
|
93
|
+
|
|
94
|
+
### Django
|
|
95
|
+
|
|
96
|
+
In `wsgi.py`:
|
|
97
|
+
|
|
98
|
+
```python
|
|
99
|
+
from django.core.wsgi import get_wsgi_application
|
|
100
|
+
from onlinewebdirectory_site import WSGIMiddleware
|
|
101
|
+
|
|
102
|
+
application = WSGIMiddleware(get_wsgi_application(), skip=("/static/", "/admin/"))
|
|
103
|
+
```
|
|
104
|
+
|
|
105
|
+
If you serve Django with ASGI, do the same in `asgi.py` with `ASGIMiddleware(get_asgi_application())`.
|
|
106
|
+
|
|
107
|
+
### Flask
|
|
108
|
+
|
|
109
|
+
```python
|
|
110
|
+
from flask import Flask
|
|
111
|
+
from onlinewebdirectory_site import WSGIMiddleware
|
|
112
|
+
|
|
113
|
+
app = Flask(__name__)
|
|
114
|
+
app.wsgi_app = WSGIMiddleware(app.wsgi_app)
|
|
115
|
+
```
|
|
116
|
+
|
|
117
|
+
### FastAPI
|
|
118
|
+
|
|
119
|
+
```python
|
|
120
|
+
from fastapi import FastAPI
|
|
121
|
+
from onlinewebdirectory_site import ASGIMiddleware
|
|
122
|
+
|
|
123
|
+
app = FastAPI()
|
|
124
|
+
app.add_middleware(ASGIMiddleware)
|
|
125
|
+
```
|
|
126
|
+
|
|
127
|
+
### What the middleware does
|
|
128
|
+
|
|
129
|
+
- Answers `/.well-known/owd-site.txt` with the proof as `text/plain`, only while a proof is set.
|
|
130
|
+
- Counts a request when its user agent contains one of the agent words the service lists. It keeps the agent's name, the page path without the query string, and the day (UTC). Nothing else.
|
|
131
|
+
- Holds the counts in memory, one table per process, at most 500 rows. Past that, new pages are counted together as `(other pages)`.
|
|
132
|
+
- Hands the counts to the service about once an hour, from a background thread, in calls of at most 200 rows. A call that fails is sent again later under the same batch id, so it is never counted twice. It also hands them over when the process stops.
|
|
133
|
+
- Counts nothing when no key is set.
|
|
134
|
+
- Never blocks or breaks a request. Every failure in counting is swallowed.
|
|
135
|
+
|
|
136
|
+
Options, all optional: `skip` (path beginnings that are never counted), `every` (seconds between hand-overs, default 3600), `flush_on_exit` (default `True`), and the llms.txt options below.
|
|
137
|
+
|
|
138
|
+
## The badge
|
|
139
|
+
|
|
140
|
+
The badge is a small picture that links to your site's page in the directory. It is never shown automatically. Place it where you choose:
|
|
141
|
+
|
|
142
|
+
```python
|
|
143
|
+
from onlinewebdirectory_site import default_site
|
|
144
|
+
|
|
145
|
+
badge = default_site().badge_html() # "" until your listing is live
|
|
146
|
+
```
|
|
147
|
+
|
|
148
|
+
The HTML is cut down to exactly one link holding one image, https only. Mark it as safe in your template (`{{ badge|safe }}`). `badge_html()` uses what the service last said and never calls the service, so it cannot slow a page down. To make it yourself from a site answer, call `badge_html(site)`.
|
|
149
|
+
|
|
150
|
+
When the badge is on your home page, run `python -m onlinewebdirectory_site badge`. The service looks for it and says whether it was found.
|
|
151
|
+
|
|
152
|
+
## llms.txt and robots.txt (optional, off by default)
|
|
153
|
+
|
|
154
|
+
To answer `/llms.txt`, give the middleware your own text or a list of your public pages:
|
|
155
|
+
|
|
156
|
+
```python
|
|
157
|
+
application = WSGIMiddleware(
|
|
158
|
+
application,
|
|
159
|
+
site_name="My shop",
|
|
160
|
+
site_about="Hand-made candles, posted worldwide.",
|
|
161
|
+
llms_pages=[
|
|
162
|
+
{"title": "Home", "url": "https://YOUR-DOMAIN/"},
|
|
163
|
+
{"title": "Delivery", "url": "https://YOUR-DOMAIN/delivery", "about": "Costs and times."},
|
|
164
|
+
],
|
|
165
|
+
)
|
|
166
|
+
```
|
|
167
|
+
|
|
168
|
+
or `llms_text="..."` for your own words. Remove the option to switch it off again. If your site already has a real `/llms.txt`, leave these options out.
|
|
169
|
+
|
|
170
|
+
To let named AI bots in, add lines to your own robots.txt:
|
|
171
|
+
|
|
172
|
+
```python
|
|
173
|
+
from onlinewebdirectory_site import Client, robots_bots, robots_lines
|
|
174
|
+
|
|
175
|
+
print(robots_lines(robots_bots(Client().report()))) # the bots your fix report names
|
|
176
|
+
print(robots_lines(["GPTBot", "ClaudeBot"])) # or bots you choose
|
|
177
|
+
```
|
|
178
|
+
|
|
179
|
+
This package does not change your files. You add the lines and you can take them out again.
|
|
180
|
+
|
|
181
|
+
## Command line
|
|
182
|
+
|
|
183
|
+
```
|
|
184
|
+
python -m onlinewebdirectory_site connect YOUR-DOMAIN
|
|
185
|
+
python -m onlinewebdirectory_site verify [--platform django]
|
|
186
|
+
python -m onlinewebdirectory_site status
|
|
187
|
+
python -m onlinewebdirectory_site listing --email you@YOUR-DOMAIN --name "My shop" --about "Hand-made candles, posted worldwide." --kind shop [--contact hello@YOUR-DOMAIN]
|
|
188
|
+
python -m onlinewebdirectory_site visits
|
|
189
|
+
python -m onlinewebdirectory_site buy monitor --email you@YOUR-DOMAIN
|
|
190
|
+
python -m onlinewebdirectory_site buy report --email you@YOUR-DOMAIN
|
|
191
|
+
python -m onlinewebdirectory_site report
|
|
192
|
+
python -m onlinewebdirectory_site recheck
|
|
193
|
+
python -m onlinewebdirectory_site badge
|
|
194
|
+
```
|
|
195
|
+
|
|
196
|
+
- `status` shows pass or fail, the score, the date checked, your listing, what is paid and the prices. After the result it shows what to do next, in the service's own words, with the command or the page for each step.
|
|
197
|
+
- `listing` needs `--email` the first time only. Give `--name`, `--about` and `--kind` every time: the listing is saved as you send it. `--kind` is one of the kinds the service lists. `--contact` is optional: an email address at your domain or an https page on it.
|
|
198
|
+
- `buy` prints the address of the payment page. Open it in your browser to pay by card.
|
|
199
|
+
- `badge` asks the service to look for the badge on your home page, at most once every ten minutes. Once it is found, the link from your directory page to your site is a normal followed link.
|
|
200
|
+
- When the service refuses something, its own words are printed and the command exits with 1.
|
|
201
|
+
|
|
202
|
+
The same calls are on `Client` for your own code: `site()`, `listing()`, `visits()`, `order()`, `report()`, `recheck()`, `badge_check()`. A refusal raises `OWDError` with the service's words in `message` and the status in `status`. When the service answers 401 the key is no longer valid: it is forgotten and you connect again.
|
|
203
|
+
|
|
204
|
+
## External services
|
|
205
|
+
|
|
206
|
+
This package connects to Online Web Directory (https://onlinewebdirectory.net), which provides the check, the listing and the reports. Nothing is sent until you run `connect`.
|
|
207
|
+
|
|
208
|
+
- When you connect: your site address is sent, and the service reads one proof file from your site (`/.well-known/owd-site.txt`) to confirm the request came from it. The name of the integration and its version are sent with it.
|
|
209
|
+
- When you run `status`, `visits`, `report` or `recheck`, and about once an hour while your site runs: the package asks the service for your site's result, listing and counts, and for the list of agents to count.
|
|
210
|
+
- When you run `badge`: the service reads your home page once to look for the badge.
|
|
211
|
+
- When you save your listing: the name, description, kind of site, contact for agents and the email address you enter are sent.
|
|
212
|
+
- Once an hour: counts of requests from AI agents are sent. Each count holds the agent's name, the page path and the day. No IP address, no visitor data and nothing about people is collected or sent.
|
|
213
|
+
- When you buy something: the email address you enter is sent, and you are given the address of a payment page run by Stripe.
|
|
214
|
+
|
|
215
|
+
Terms: https://onlinewebdirectory.net/terms
|
|
216
|
+
Privacy: https://onlinewebdirectory.net/privacy
|
|
217
|
+
|
|
218
|
+
## Questions
|
|
219
|
+
|
|
220
|
+
**Why is my count of AI agents lower than my server logs?** Requests answered before your application runs (a CDN, a full-page cache, static files served by the web server) never reach the middleware, so they are not counted. Requests that arrive in the first moments after a process starts, before the list of agents has been read, are not counted either.
|
|
221
|
+
|
|
222
|
+
**Does the badge add a link to my site without asking?** No. It appears only where you place it.
|
|
223
|
+
|
|
224
|
+
## Licence
|
|
225
|
+
|
|
226
|
+
MIT. See `LICENSE`.
|
|
227
|
+
|
|
228
|
+
## Tests
|
|
229
|
+
|
|
230
|
+
`tests/test_e2e.py` runs against a local copy of the service and refuses to run against the live one.
|
|
231
|
+
|
|
232
|
+
## Changelog
|
|
233
|
+
|
|
234
|
+
1.0.0: first release.
|
|
235
|
+
|
|
236
|
+
## Find us
|
|
237
|
+
|
|
238
|
+
- Website: [onlinewebdirectory.net](https://onlinewebdirectory.net)
|
|
239
|
+
- Check any site, free: [onlinewebdirectory.net/check](https://onlinewebdirectory.net/check)
|
|
240
|
+
- Blog: [onlinewebdirectory.net/blog](https://onlinewebdirectory.net/blog/)
|
|
241
|
+
- Moltbook: [onlinewebdirectory](https://www.moltbook.com/u/onlinewebdirectory) and the [m/agentweb](https://www.moltbook.com/m/agentweb) community
|
|
242
|
+
- The Colony: [onlinewebdirectory](https://thecolony.cc/u/onlinewebdirectory)
|
|
243
|
+
- For agents: [the lookup skill](https://github.com/onlinewebdirectory/onlinewebdirectory-skill) and the [MCP server](https://onlinewebdirectory.net/install.md)
|
|
244
|
+
- Source and issues: [github.com/onlinewebdirectory/site-integrations](https://github.com/onlinewebdirectory/site-integrations)
|
|
245
|
+
|
|
246
|
+
---
|
|
247
|
+
|
|
248
|
+
⭐ **Found it useful? [Star the repo on GitHub](https://github.com/onlinewebdirectory/site-integrations).** It takes one click and helps others find it.
|
|
@@ -0,0 +1,228 @@
|
|
|
1
|
+
# Online Web Directory for Python sites
|
|
2
|
+
|
|
3
|
+
[](https://github.com/onlinewebdirectory/site-integrations)
|
|
4
|
+
|
|
5
|
+
### ⭐ [Star this repo on GitHub](https://github.com/onlinewebdirectory/site-integrations)
|
|
6
|
+
|
|
7
|
+
One click. It is how other people with the same problem find this.
|
|
8
|
+
|
|
9
|
+
[](https://onlinewebdirectory.net)
|
|
10
|
+
|
|
11
|
+
**[Website](https://onlinewebdirectory.net)** · [Check your site, free](https://onlinewebdirectory.net/check) · [Confirm your listing, free](https://onlinewebdirectory.net/confirm) · [Pricing](https://onlinewebdirectory.net/pricing) · [Blog](https://onlinewebdirectory.net/blog/) · [Moltbook](https://www.moltbook.com/u/onlinewebdirectory) · [m/agentweb](https://www.moltbook.com/m/agentweb) · [The Colony](https://thecolony.cc/u/onlinewebdirectory)
|
|
12
|
+
|
|
13
|
+
[](https://www.npmjs.com/package/onlinewebdirectory-site) [](https://rubygems.org/gems/onlinewebdirectory-site) [](https://packagist.org/packages/onlinewebdirectory/site) [](https://github.com/onlinewebdirectory/site-integrations/blob/main/LICENSE)
|
|
14
|
+
|
|
15
|
+
See whether AI agents can get into your site, confirm your free directory listing, and count the AI agents that request your pages.
|
|
16
|
+
|
|
17
|
+
Online Web Directory is where AI agents look a website up before they fetch it. This package connects a site built on Django, Flask, FastAPI or any other WSGI or ASGI framework to the directory.
|
|
18
|
+
|
|
19
|
+
It uses the Python standard library only. Python 3.9 or newer.
|
|
20
|
+
|
|
21
|
+
## Free
|
|
22
|
+
|
|
23
|
+
- Pass or fail: can an AI agent with a plain web client get into your site? Plus a readiness score out of 100 and the date it was checked.
|
|
24
|
+
- Confirm your free listing from the command line, with no email round trip. Tell agents what your site is, in your own words.
|
|
25
|
+
- A count of requests from AI agents and crawlers (GPTBot, ClaudeBot, PerplexityBot and others), counted on your own server.
|
|
26
|
+
- A directory badge you can place in a template. It is never shown unless you place it.
|
|
27
|
+
|
|
28
|
+
## Paid, bought from the command line
|
|
29
|
+
|
|
30
|
+
- Monitor: which agents came, which pages they asked for and the count for each day. A daily check, and an email when the result changes. You can ask for a fresh look after you change your site with `recheck`.
|
|
31
|
+
- Fix report: every point behind your score, what was found, why it matters and how to fix it. Where this package can help with the fix (robots.txt lines for AI bots, an llms.txt made from your pages) the report says so.
|
|
32
|
+
|
|
33
|
+
Prices come from the service and are shown by `status` before you pay. Payment is by card on a secure payment page.
|
|
34
|
+
|
|
35
|
+
## Install
|
|
36
|
+
|
|
37
|
+
```
|
|
38
|
+
pip install onlinewebdirectory_site
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
## Connect your site
|
|
42
|
+
|
|
43
|
+
Run these where your site's code lives. Replace YOUR-DOMAIN with your site's address.
|
|
44
|
+
|
|
45
|
+
```
|
|
46
|
+
python -m onlinewebdirectory_site connect YOUR-DOMAIN
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
This saves a proof and its secret in `.owd-site.json` and prints one line, `OWD_SITE_PROOF=...`. If your site runs somewhere else, set that line in its environment and deploy. The middleware then answers `/.well-known/owd-site.txt` with the proof. The proof works for one hour.
|
|
50
|
+
|
|
51
|
+
```
|
|
52
|
+
python -m onlinewebdirectory_site verify
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
The service reads the proof file once and gives you a key. `verify` prints `OWD_SITE_KEY=...` one time: set it in the environment where your site runs. It also saves the key in `.owd-site.json` and removes the proof and secret from it. You can then remove `OWD_SITE_PROOF`. Do not run `verify` in a loop: the service rations it.
|
|
56
|
+
|
|
57
|
+
The proof file has to open at the top of your domain. A site that lives in a sub-folder cannot connect yet.
|
|
58
|
+
|
|
59
|
+
### Keep `.owd-site.json` private
|
|
60
|
+
|
|
61
|
+
The file is made with mode 0600. It holds your key. Add it to `.gitignore` and never put it in version control. Set `OWD_SITE_FILE` to keep it somewhere else.
|
|
62
|
+
|
|
63
|
+
## Settings
|
|
64
|
+
|
|
65
|
+
| Environment | What it is |
|
|
66
|
+
| --- | --- |
|
|
67
|
+
| `OWD_SITE_KEY` | Your site key. When it is not set, the key is read from `.owd-site.json`. |
|
|
68
|
+
| `OWD_SITE_PROOF` | The proof to serve while you connect. When it is not set, the proof is read from `.owd-site.json`. |
|
|
69
|
+
| `OWD_SITE_FILE` | Where `.owd-site.json` is kept. Default: the folder the process starts in. |
|
|
70
|
+
| `OWD_API` | The service address. Default: `https://onlinewebdirectory.net`. |
|
|
71
|
+
|
|
72
|
+
## Add the middleware
|
|
73
|
+
|
|
74
|
+
### Django
|
|
75
|
+
|
|
76
|
+
In `wsgi.py`:
|
|
77
|
+
|
|
78
|
+
```python
|
|
79
|
+
from django.core.wsgi import get_wsgi_application
|
|
80
|
+
from onlinewebdirectory_site import WSGIMiddleware
|
|
81
|
+
|
|
82
|
+
application = WSGIMiddleware(get_wsgi_application(), skip=("/static/", "/admin/"))
|
|
83
|
+
```
|
|
84
|
+
|
|
85
|
+
If you serve Django with ASGI, do the same in `asgi.py` with `ASGIMiddleware(get_asgi_application())`.
|
|
86
|
+
|
|
87
|
+
### Flask
|
|
88
|
+
|
|
89
|
+
```python
|
|
90
|
+
from flask import Flask
|
|
91
|
+
from onlinewebdirectory_site import WSGIMiddleware
|
|
92
|
+
|
|
93
|
+
app = Flask(__name__)
|
|
94
|
+
app.wsgi_app = WSGIMiddleware(app.wsgi_app)
|
|
95
|
+
```
|
|
96
|
+
|
|
97
|
+
### FastAPI
|
|
98
|
+
|
|
99
|
+
```python
|
|
100
|
+
from fastapi import FastAPI
|
|
101
|
+
from onlinewebdirectory_site import ASGIMiddleware
|
|
102
|
+
|
|
103
|
+
app = FastAPI()
|
|
104
|
+
app.add_middleware(ASGIMiddleware)
|
|
105
|
+
```
|
|
106
|
+
|
|
107
|
+
### What the middleware does
|
|
108
|
+
|
|
109
|
+
- Answers `/.well-known/owd-site.txt` with the proof as `text/plain`, only while a proof is set.
|
|
110
|
+
- Counts a request when its user agent contains one of the agent words the service lists. It keeps the agent's name, the page path without the query string, and the day (UTC). Nothing else.
|
|
111
|
+
- Holds the counts in memory, one table per process, at most 500 rows. Past that, new pages are counted together as `(other pages)`.
|
|
112
|
+
- Hands the counts to the service about once an hour, from a background thread, in calls of at most 200 rows. A call that fails is sent again later under the same batch id, so it is never counted twice. It also hands them over when the process stops.
|
|
113
|
+
- Counts nothing when no key is set.
|
|
114
|
+
- Never blocks or breaks a request. Every failure in counting is swallowed.
|
|
115
|
+
|
|
116
|
+
Options, all optional: `skip` (path beginnings that are never counted), `every` (seconds between hand-overs, default 3600), `flush_on_exit` (default `True`), and the llms.txt options below.
|
|
117
|
+
|
|
118
|
+
## The badge
|
|
119
|
+
|
|
120
|
+
The badge is a small picture that links to your site's page in the directory. It is never shown automatically. Place it where you choose:
|
|
121
|
+
|
|
122
|
+
```python
|
|
123
|
+
from onlinewebdirectory_site import default_site
|
|
124
|
+
|
|
125
|
+
badge = default_site().badge_html() # "" until your listing is live
|
|
126
|
+
```
|
|
127
|
+
|
|
128
|
+
The HTML is cut down to exactly one link holding one image, https only. Mark it as safe in your template (`{{ badge|safe }}`). `badge_html()` uses what the service last said and never calls the service, so it cannot slow a page down. To make it yourself from a site answer, call `badge_html(site)`.
|
|
129
|
+
|
|
130
|
+
When the badge is on your home page, run `python -m onlinewebdirectory_site badge`. The service looks for it and says whether it was found.
|
|
131
|
+
|
|
132
|
+
## llms.txt and robots.txt (optional, off by default)
|
|
133
|
+
|
|
134
|
+
To answer `/llms.txt`, give the middleware your own text or a list of your public pages:
|
|
135
|
+
|
|
136
|
+
```python
|
|
137
|
+
application = WSGIMiddleware(
|
|
138
|
+
application,
|
|
139
|
+
site_name="My shop",
|
|
140
|
+
site_about="Hand-made candles, posted worldwide.",
|
|
141
|
+
llms_pages=[
|
|
142
|
+
{"title": "Home", "url": "https://YOUR-DOMAIN/"},
|
|
143
|
+
{"title": "Delivery", "url": "https://YOUR-DOMAIN/delivery", "about": "Costs and times."},
|
|
144
|
+
],
|
|
145
|
+
)
|
|
146
|
+
```
|
|
147
|
+
|
|
148
|
+
or `llms_text="..."` for your own words. Remove the option to switch it off again. If your site already has a real `/llms.txt`, leave these options out.
|
|
149
|
+
|
|
150
|
+
To let named AI bots in, add lines to your own robots.txt:
|
|
151
|
+
|
|
152
|
+
```python
|
|
153
|
+
from onlinewebdirectory_site import Client, robots_bots, robots_lines
|
|
154
|
+
|
|
155
|
+
print(robots_lines(robots_bots(Client().report()))) # the bots your fix report names
|
|
156
|
+
print(robots_lines(["GPTBot", "ClaudeBot"])) # or bots you choose
|
|
157
|
+
```
|
|
158
|
+
|
|
159
|
+
This package does not change your files. You add the lines and you can take them out again.
|
|
160
|
+
|
|
161
|
+
## Command line
|
|
162
|
+
|
|
163
|
+
```
|
|
164
|
+
python -m onlinewebdirectory_site connect YOUR-DOMAIN
|
|
165
|
+
python -m onlinewebdirectory_site verify [--platform django]
|
|
166
|
+
python -m onlinewebdirectory_site status
|
|
167
|
+
python -m onlinewebdirectory_site listing --email you@YOUR-DOMAIN --name "My shop" --about "Hand-made candles, posted worldwide." --kind shop [--contact hello@YOUR-DOMAIN]
|
|
168
|
+
python -m onlinewebdirectory_site visits
|
|
169
|
+
python -m onlinewebdirectory_site buy monitor --email you@YOUR-DOMAIN
|
|
170
|
+
python -m onlinewebdirectory_site buy report --email you@YOUR-DOMAIN
|
|
171
|
+
python -m onlinewebdirectory_site report
|
|
172
|
+
python -m onlinewebdirectory_site recheck
|
|
173
|
+
python -m onlinewebdirectory_site badge
|
|
174
|
+
```
|
|
175
|
+
|
|
176
|
+
- `status` shows pass or fail, the score, the date checked, your listing, what is paid and the prices. After the result it shows what to do next, in the service's own words, with the command or the page for each step.
|
|
177
|
+
- `listing` needs `--email` the first time only. Give `--name`, `--about` and `--kind` every time: the listing is saved as you send it. `--kind` is one of the kinds the service lists. `--contact` is optional: an email address at your domain or an https page on it.
|
|
178
|
+
- `buy` prints the address of the payment page. Open it in your browser to pay by card.
|
|
179
|
+
- `badge` asks the service to look for the badge on your home page, at most once every ten minutes. Once it is found, the link from your directory page to your site is a normal followed link.
|
|
180
|
+
- When the service refuses something, its own words are printed and the command exits with 1.
|
|
181
|
+
|
|
182
|
+
The same calls are on `Client` for your own code: `site()`, `listing()`, `visits()`, `order()`, `report()`, `recheck()`, `badge_check()`. A refusal raises `OWDError` with the service's words in `message` and the status in `status`. When the service answers 401 the key is no longer valid: it is forgotten and you connect again.
|
|
183
|
+
|
|
184
|
+
## External services
|
|
185
|
+
|
|
186
|
+
This package connects to Online Web Directory (https://onlinewebdirectory.net), which provides the check, the listing and the reports. Nothing is sent until you run `connect`.
|
|
187
|
+
|
|
188
|
+
- When you connect: your site address is sent, and the service reads one proof file from your site (`/.well-known/owd-site.txt`) to confirm the request came from it. The name of the integration and its version are sent with it.
|
|
189
|
+
- When you run `status`, `visits`, `report` or `recheck`, and about once an hour while your site runs: the package asks the service for your site's result, listing and counts, and for the list of agents to count.
|
|
190
|
+
- When you run `badge`: the service reads your home page once to look for the badge.
|
|
191
|
+
- When you save your listing: the name, description, kind of site, contact for agents and the email address you enter are sent.
|
|
192
|
+
- Once an hour: counts of requests from AI agents are sent. Each count holds the agent's name, the page path and the day. No IP address, no visitor data and nothing about people is collected or sent.
|
|
193
|
+
- When you buy something: the email address you enter is sent, and you are given the address of a payment page run by Stripe.
|
|
194
|
+
|
|
195
|
+
Terms: https://onlinewebdirectory.net/terms
|
|
196
|
+
Privacy: https://onlinewebdirectory.net/privacy
|
|
197
|
+
|
|
198
|
+
## Questions
|
|
199
|
+
|
|
200
|
+
**Why is my count of AI agents lower than my server logs?** Requests answered before your application runs (a CDN, a full-page cache, static files served by the web server) never reach the middleware, so they are not counted. Requests that arrive in the first moments after a process starts, before the list of agents has been read, are not counted either.
|
|
201
|
+
|
|
202
|
+
**Does the badge add a link to my site without asking?** No. It appears only where you place it.
|
|
203
|
+
|
|
204
|
+
## Licence
|
|
205
|
+
|
|
206
|
+
MIT. See `LICENSE`.
|
|
207
|
+
|
|
208
|
+
## Tests
|
|
209
|
+
|
|
210
|
+
`tests/test_e2e.py` runs against a local copy of the service and refuses to run against the live one.
|
|
211
|
+
|
|
212
|
+
## Changelog
|
|
213
|
+
|
|
214
|
+
1.0.0: first release.
|
|
215
|
+
|
|
216
|
+
## Find us
|
|
217
|
+
|
|
218
|
+
- Website: [onlinewebdirectory.net](https://onlinewebdirectory.net)
|
|
219
|
+
- Check any site, free: [onlinewebdirectory.net/check](https://onlinewebdirectory.net/check)
|
|
220
|
+
- Blog: [onlinewebdirectory.net/blog](https://onlinewebdirectory.net/blog/)
|
|
221
|
+
- Moltbook: [onlinewebdirectory](https://www.moltbook.com/u/onlinewebdirectory) and the [m/agentweb](https://www.moltbook.com/m/agentweb) community
|
|
222
|
+
- The Colony: [onlinewebdirectory](https://thecolony.cc/u/onlinewebdirectory)
|
|
223
|
+
- For agents: [the lookup skill](https://github.com/onlinewebdirectory/onlinewebdirectory-skill) and the [MCP server](https://onlinewebdirectory.net/install.md)
|
|
224
|
+
- Source and issues: [github.com/onlinewebdirectory/site-integrations](https://github.com/onlinewebdirectory/site-integrations)
|
|
225
|
+
|
|
226
|
+
---
|
|
227
|
+
|
|
228
|
+
⭐ **Found it useful? [Star the repo on GitHub](https://github.com/onlinewebdirectory/site-integrations).** It takes one click and helps others find it.
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
"""Online Web Directory for Python sites.
|
|
2
|
+
|
|
3
|
+
See whether AI agents can get into your site, confirm your free directory
|
|
4
|
+
listing, and count the AI agents that request your pages.
|
|
5
|
+
"""
|
|
6
|
+
|
|
7
|
+
from .badge import badge_html
|
|
8
|
+
from .client import VERSION, Client, OWDError
|
|
9
|
+
from .files import llms_text, robots_bots, robots_lines
|
|
10
|
+
from .middleware import ASGIMiddleware, WSGIMiddleware
|
|
11
|
+
from .site import Site, default_site
|
|
12
|
+
from .store import Store
|
|
13
|
+
from .visits import Visits
|
|
14
|
+
|
|
15
|
+
__version__ = VERSION
|
|
16
|
+
__all__ = [
|
|
17
|
+
"ASGIMiddleware", "Client", "OWDError", "Site", "Store", "Visits", "WSGIMiddleware",
|
|
18
|
+
"badge_html", "default_site", "llms_text", "robots_bots", "robots_lines",
|
|
19
|
+
]
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
"""The directory badge: a small picture that links to this site's page in the
|
|
2
|
+
directory. Shown only where the owner puts it. Never shown automatically."""
|
|
3
|
+
|
|
4
|
+
import html
|
|
5
|
+
import re
|
|
6
|
+
|
|
7
|
+
_A = re.compile(r"<a\b([^>]*)>(.*?)</a\s*>", re.I | re.S)
|
|
8
|
+
_IMG = re.compile(r"<img\b([^>]*)>", re.I | re.S)
|
|
9
|
+
_ATTR = re.compile(r"""([a-zA-Z][a-zA-Z0-9_:-]*)\s*=\s*(?:"([^"]*)"|'([^']*)'|([^\s"'>]+))""")
|
|
10
|
+
_HTTPS = re.compile(r"\Ahttps://[^\s\"'<>\\]+\Z")
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
def _attributes(text):
|
|
14
|
+
found = {}
|
|
15
|
+
for match in _ATTR.finditer(text or ""):
|
|
16
|
+
name = match.group(1).lower()
|
|
17
|
+
value = next((group for group in match.groups()[1:] if group is not None), "")
|
|
18
|
+
found.setdefault(name, html.unescape(value).strip())
|
|
19
|
+
return found
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
def badge_html(source):
|
|
23
|
+
"""Cuts badge HTML down to exactly one <a href> holding one <img src alt width height>.
|
|
24
|
+
|
|
25
|
+
https only. Everything else is dropped. Returns '' when no safe badge is left.
|
|
26
|
+
"""
|
|
27
|
+
if isinstance(source, dict):
|
|
28
|
+
badge = source.get("badge")
|
|
29
|
+
source = badge.get("html") if isinstance(badge, dict) else None
|
|
30
|
+
if not isinstance(source, str) or not source:
|
|
31
|
+
return ""
|
|
32
|
+
for link in _A.finditer(source):
|
|
33
|
+
href = _attributes(link.group(1)).get("href", "")
|
|
34
|
+
image = _IMG.search(link.group(2))
|
|
35
|
+
if not image or not _HTTPS.match(href):
|
|
36
|
+
continue
|
|
37
|
+
attributes = _attributes(image.group(1))
|
|
38
|
+
src = attributes.get("src", "")
|
|
39
|
+
if not _HTTPS.match(src):
|
|
40
|
+
continue
|
|
41
|
+
out = '<a href="%s"><img src="%s" alt="%s"' % (html.escape(href, True), html.escape(src, True), html.escape(attributes.get("alt", ""), True))
|
|
42
|
+
for name in ("width", "height"):
|
|
43
|
+
if re.match(r"\A[0-9]{1,4}\Z", attributes.get(name, "")):
|
|
44
|
+
out += ' %s="%s"' % (name, attributes[name])
|
|
45
|
+
return out + "></a>"
|
|
46
|
+
return ""
|