Add base repo
This commit is contained in:
parent
7d21cf494e
commit
d6a5b02012
10
src/api/__init__.py
Normal file
10
src/api/__init__.py
Normal file
@ -0,0 +1,10 @@
|
||||
from flask_restx import Api
|
||||
|
||||
|
||||
api = Api(
|
||||
version='1.0',
|
||||
title='Meme Search Engine',
|
||||
description='A CLIP based meme search engine',
|
||||
doc='/doc/'
|
||||
)
|
||||
|
17
src/app.py
Executable file
17
src/app.py
Executable file
@ -0,0 +1,17 @@
|
||||
#!/usr/bin/python3
|
||||
# Entry point
|
||||
|
||||
from flask import Flask
|
||||
from api import api
|
||||
from config import config, setLogLevel
|
||||
import os
|
||||
|
||||
setLogLevel()
|
||||
|
||||
port = config["server.port"]
|
||||
host = config["server.host"]
|
||||
|
||||
app = Flask(__name__)
|
||||
api.init_app(app)
|
||||
|
||||
app.run(host=host, port=port)
|
27
src/config.py
Normal file
27
src/config.py
Normal file
@ -0,0 +1,27 @@
|
||||
# Load configurationa YAML
|
||||
|
||||
import envyaml
|
||||
import os
|
||||
import logging
|
||||
|
||||
config = envyaml.envyaml(os.environ.get('CONFIG_PATH', 'config.yaml'))
|
||||
|
||||
def setLogLevel():
|
||||
"""
|
||||
Set the logging level based on the config
|
||||
"""
|
||||
|
||||
logLevel = config["app.log"]
|
||||
if logLevel == "DEBUG":
|
||||
logging.basicConfig(level=logging.DEBUG)
|
||||
elif logLevel == "INFO":
|
||||
logging.basicConfig(level=logging.INFO)
|
||||
elif logLevel == "WARNING":
|
||||
logging.basicConfig(level=logging.WARNING)
|
||||
elif logLevel == "ERROR":
|
||||
logging.basicConfig(level=logging.ERROR)
|
||||
elif logLevel == "CRITICAL":
|
||||
logging.basicConfig(level=logging.CRITICAL)
|
||||
|
||||
logging.info("Logging level set to %s", logLevel)
|
||||
|
5
src/config.yaml
Normal file
5
src/config.yaml
Normal file
@ -0,0 +1,5 @@
|
||||
app:
|
||||
port: 5000
|
||||
host: "0.0.0.0"
|
||||
log: "debug"
|
||||
|
16
src/requirements.txt
Normal file
16
src/requirements.txt
Normal file
@ -0,0 +1,16 @@
|
||||
aniso8601==9.0.1
|
||||
attrs==23.1.0
|
||||
blinker==1.6.2
|
||||
click==8.1.3
|
||||
envyaml==1.10.211231
|
||||
Flask==2.3.2
|
||||
flask-restx==1.1.0
|
||||
huggingface==0.0.1
|
||||
itsdangerous==2.1.2
|
||||
Jinja2==3.1.2
|
||||
jsonschema==4.17.3
|
||||
MarkupSafe==2.1.2
|
||||
pyrsistent==0.19.3
|
||||
pytz==2023.3
|
||||
PyYAML==6.0
|
||||
Werkzeug==2.3.3
|
Reference in New Issue
Block a user