installed packages
This commit is contained in:
@@ -4,36 +4,28 @@ import uvicorn
|
|||||||
from fastapi import FastAPI, Request, HTTPException, status
|
from fastapi import FastAPI, Request, HTTPException, status
|
||||||
from dotenv import load_dotenv
|
from dotenv import load_dotenv
|
||||||
import logging
|
import logging
|
||||||
import os
|
import time
|
||||||
|
|
||||||
app = FastAPI()
|
app = FastAPI()
|
||||||
|
|
||||||
# @app.middleware('http')
|
|
||||||
# async def check_media_type(request: Request, call_next):
|
|
||||||
# """
|
|
||||||
# Ensure only requests with content-type of application/json are handled.
|
|
||||||
# """
|
|
||||||
# content_type = request.headers.get('content-type', default=None)
|
|
||||||
# if content_type is None or not content_type.lower().startswith('application/json'):
|
|
||||||
# raise HTTPException(
|
|
||||||
# status_code=status.HTTP_415_UNSUPPORTED_MEDIA_TYPE,
|
|
||||||
# detail=f'Unsupported media type {content_type}'
|
|
||||||
# )
|
|
||||||
# response = await call_next(request)
|
|
||||||
# return response
|
|
||||||
|
|
||||||
@app.get('/')
|
@app.get('/')
|
||||||
async def root():
|
async def root():
|
||||||
return {'message': 'Welcome to Gitea Runner'}
|
return {'message': 'Welcome to Gitea Runner'}
|
||||||
|
|
||||||
@app.post('/test')
|
@app.post('/test')
|
||||||
async def test(request: Request):
|
async def test(request: Request):
|
||||||
"""
|
""" Test connection to server. """
|
||||||
Test connection to server
|
|
||||||
"""
|
|
||||||
logging.debug('Content-Type: ', request.headers.get('content-type'))
|
logging.debug('Content-Type: ', request.headers.get('content-type'))
|
||||||
return {'status': 'success'}
|
return {'status': 'success'}
|
||||||
|
|
||||||
|
@app.post('/event')
|
||||||
|
def handle_event(request: Request):
|
||||||
|
"""
|
||||||
|
Handle event from webhook
|
||||||
|
"""
|
||||||
|
time.sleep(10)
|
||||||
|
return {'status': 'success'}
|
||||||
|
|
||||||
# @app.post('/execute')
|
# @app.post('/execute')
|
||||||
|
|
||||||
# @app.before_request
|
# @app.before_request
|
||||||
@@ -63,5 +55,6 @@ if __name__ == '__main__':
|
|||||||
# port=listen_port
|
# port=listen_port
|
||||||
# )
|
# )
|
||||||
uvicorn.run(
|
uvicorn.run(
|
||||||
app=app
|
app=app,
|
||||||
|
host='0.0.0.0'
|
||||||
)
|
)
|
||||||
+10
-2
@@ -1,9 +1,17 @@
|
|||||||
|
anyio==3.7.0
|
||||||
blinker==1.6.2
|
blinker==1.6.2
|
||||||
click==8.1.3
|
click==8.1.3
|
||||||
Flask==2.3.2
|
exceptiongroup==1.1.2
|
||||||
|
fastapi==0.99.1
|
||||||
|
h11==0.14.0
|
||||||
|
idna==3.4
|
||||||
itsdangerous==2.1.2
|
itsdangerous==2.1.2
|
||||||
Jinja2==3.1.2
|
Jinja2==3.1.2
|
||||||
MarkupSafe==2.1.3
|
MarkupSafe==2.1.3
|
||||||
|
pydantic==1.10.11
|
||||||
python-dotenv==1.0.0
|
python-dotenv==1.0.0
|
||||||
waitress==2.1.2
|
sniffio==1.3.0
|
||||||
|
starlette==0.27.0
|
||||||
|
typing_extensions==4.7.1
|
||||||
|
uvicorn==0.22.0
|
||||||
Werkzeug==2.3.6
|
Werkzeug==2.3.6
|
||||||
|
|||||||
Reference in New Issue
Block a user