use hypercorn
All checks were successful
Docker Build / Build and Push Images (push) Successful in 32s

This commit is contained in:
Seaswimmer 2024-08-03 00:41:26 -04:00
parent 093d2d8fe5
commit 5da2540aee
Signed by: cswimr
GPG key ID: 3813315477F26F82
2 changed files with 25 additions and 9 deletions

View file

@ -1,15 +1,24 @@
aiohappyeyeballs==2.3.4
aiohttp==3.10.0
aiosignal==1.3.1
asgiref==3.8.1
attrs==23.2.0
blinker==1.8.2
click==8.1.7
Flask==3.0.3
frozenlist==1.4.1
h11==0.14.0
h2==4.1.0
hpack==4.0.0
Hypercorn==0.17.3
hyperframe==6.0.1
idna==3.7
itsdangerous==2.2.0
Jinja2==3.1.4
MarkupSafe==2.1.5
multidict==6.0.5
priority==2.0.0
waitress==3.0.0
Werkzeug==3.0.3
wsproto==1.2.0
yarl==1.9.4

View file

@ -73,15 +73,18 @@ async def fetch_artifact(artifact_url):
data = await response.read()
return data
async def handle_artifact(artifact_name: str):
task = await fetch_tasks()
artifact_url = f"{task}/artifacts/{artifact_name}"
artifact_data = await fetch_artifact(artifact_url)
response = Response(artifact_data)
response.headers['Content-Disposition'] = f'attachment; filename="{artifact_name}.zip"'
return response
def create_handle_artifact(artifact_name: str):
def handle_artifact():
task = asyncio.run(fetch_tasks())
artifact_url = f"{task}/artifacts/{artifact_name}"
artifact_data = asyncio.run(fetch_artifact(artifact_url))
response = Response(artifact_data)
response.headers['Content-Disposition'] = 'attachment; filename="GalacticFactory.zip"'
return response
return handle_artifact
async def handle_artifact_async():
return await handle_artifact(artifact_name)
return handle_artifact_async
for artifact_name in config.artifact_names:
route = f'/{artifact_name}'
@ -95,4 +98,8 @@ def handle_sigterm(*args):
signal.signal(signal.SIGTERM, handle_sigterm)
if __name__ == '__main__':
app.run(debug=config.debug, host='0.0.0.0', port=80)
from hypercorn.asyncio import serve
from hypercorn.config import Config as HypercornConfig
h_config = HypercornConfig()
h_config.bind = ["0.0.0.0:80"]
asyncio.run(serve(app=app, config=h_config))