installed packages
This commit is contained in:
@@ -4,36 +4,28 @@ import uvicorn
|
||||
from fastapi import FastAPI, Request, HTTPException, status
|
||||
from dotenv import load_dotenv
|
||||
import logging
|
||||
import os
|
||||
import time
|
||||
|
||||
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('/')
|
||||
async def root():
|
||||
return {'message': 'Welcome to Gitea Runner'}
|
||||
|
||||
@app.post('/test')
|
||||
async def test(request: Request):
|
||||
"""
|
||||
Test connection to server
|
||||
"""
|
||||
""" Test connection to server. """
|
||||
logging.debug('Content-Type: ', request.headers.get('content-type'))
|
||||
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.before_request
|
||||
@@ -63,5 +55,6 @@ if __name__ == '__main__':
|
||||
# port=listen_port
|
||||
# )
|
||||
uvicorn.run(
|
||||
app=app
|
||||
app=app,
|
||||
host='0.0.0.0'
|
||||
)
|
||||
Reference in New Issue
Block a user