Update server.py
This commit is contained in:
parent
1718891a06
commit
26f72c6fb0
1 changed files with 4 additions and 2 deletions
|
@ -1,5 +1,6 @@
|
||||||
#!/usr/bin/python3
|
#!/usr/bin/python3
|
||||||
import asyncio, traceback, socket, ssl
|
import asyncio, traceback, socket, ssl
|
||||||
|
from urllib.parse import urlparse
|
||||||
from flask import Flask, request, redirect
|
from flask import Flask, request, redirect
|
||||||
from hypercorn.config import Config
|
from hypercorn.config import Config
|
||||||
from hypercorn.asyncio import serve
|
from hypercorn.asyncio import serve
|
||||||
|
@ -34,8 +35,9 @@ def relay():
|
||||||
title = "Something went wrong..."
|
title = "Something went wrong..."
|
||||||
try:
|
try:
|
||||||
gsocket = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
|
gsocket = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
|
||||||
gemsocket = ssl.create_default_context().wrap_socket(gsocket)
|
fulladdr = "gemini://" + url
|
||||||
gemsocket.connect((url, 1965))
|
gemsocket = ssl.create_default_context().wrap_socket(gsocket, server_hostname=urlparse(fulladdr).hostname)
|
||||||
|
gemsocket.connect((urlparse(fulladdr).hostname, 1965))
|
||||||
gemsocket.send(bytes("gemini://" + url + "\r\n", "UTF-8"))
|
gemsocket.send(bytes("gemini://" + url + "\r\n", "UTF-8"))
|
||||||
received = ""
|
received = ""
|
||||||
while True:
|
while True:
|
||||||
|
|
Loading…
Add table
Reference in a new issue