Update other examples
This commit is contained in:
parent
43907a0e44
commit
b7c3e43ac4
|
@ -15,7 +15,6 @@ requests. Try requesting this endpoint over two connections simultaneously.
|
|||
> jetforce-client gemini://localhost
|
||||
> jetforce-client gemini://localhost
|
||||
"""
|
||||
|
||||
import time
|
||||
|
||||
from jetforce import GeminiServer, JetforceApplication, Response, Status
|
||||
|
|
|
@ -2,10 +2,15 @@
|
|||
A simple guestbook application that accepts and displays text messages.
|
||||
|
||||
This is an example of how to return a 10 INPUT request to the client and
|
||||
retrieve their response by parsing the URL query string. This example stores
|
||||
the guestbook inside of a persistent sqlite database.
|
||||
"""
|
||||
retrieve their response by parsing the URL query string.
|
||||
|
||||
This example stores the guestbook inside of a persistent sqlite database.
|
||||
Because each request will run inside of a separate thread, we must create a new
|
||||
connection object inside of the request handler instead of re-using a global
|
||||
database connection. This thread-safety can be disabled in sqlite3 by using the
|
||||
check_same_thread=False argument, but then it's up to you to ensure that only
|
||||
connection request is writing to the database at any given time.
|
||||
"""
|
||||
import sqlite3
|
||||
from datetime import datetime
|
||||
|
||||
|
|
|
@ -1,15 +1,22 @@
|
|||
"""
|
||||
This is an example of setting up a Gemini server to proxy requests to other
|
||||
protocols. This application will accept HTTP URLs, download and render them
|
||||
locally using the `w3m` tool, and render the output to the client as plain text.
|
||||
A server that proxies HTTP websites over gemini.
|
||||
|
||||
This example demonstrates how your application routes aren't just limited to
|
||||
gemini URLs. The server will accept any HTTP URL, download the page and
|
||||
render it using the external `w3m` tool, and then render the output to the
|
||||
client as plain-text.
|
||||
|
||||
Most gemini clients won't be able to make this request, because the hostname
|
||||
in the URL doesn't match the hostname of the server. You can test this out
|
||||
using jetforce-client like this:
|
||||
|
||||
> jetforce-client https://mozz.us --host localhost
|
||||
"""
|
||||
import asyncio
|
||||
import subprocess
|
||||
|
||||
import jetforce
|
||||
from jetforce import Response, Status
|
||||
from jetforce import GeminiServer, JetforceApplication, Response, Status
|
||||
|
||||
app = jetforce.JetforceApplication()
|
||||
app = JetforceApplication()
|
||||
|
||||
|
||||
@app.route(scheme="https", strict_hostname=False)
|
||||
|
@ -26,15 +33,5 @@ def proxy_request(request):
|
|||
|
||||
|
||||
if __name__ == "__main__":
|
||||
args = jetforce.command_line_parser().parse_args()
|
||||
ssl_context = jetforce.make_ssl_context(
|
||||
args.hostname, args.certfile, args.keyfile, args.cafile, args.capath
|
||||
)
|
||||
server = jetforce.GeminiServer(
|
||||
host=args.host,
|
||||
port=args.port,
|
||||
ssl_context=ssl_context,
|
||||
hostname=args.hostname,
|
||||
app=app,
|
||||
)
|
||||
asyncio.run(server.run())
|
||||
server = GeminiServer(app)
|
||||
server.run()
|
||||
|
|
|
@ -3,6 +3,8 @@ isort:skip_file
|
|||
"""
|
||||
from .__version__ import __version__
|
||||
from .app.base import JetforceApplication, Request, Response, RoutePattern, Status
|
||||
from .app.static import StaticDirectoryApplication
|
||||
from .app.composite import CompositeApplication
|
||||
from .protocol import GeminiProtocol
|
||||
from .server import GeminiServer
|
||||
|
||||
|
|
Loading…
Reference in New Issue