Skip to content

Commit

Permalink
feat: add main func
Browse files Browse the repository at this point in the history
  • Loading branch information
HelloLindo committed Jun 13, 2024
1 parent cbff4cb commit 1e94223
Show file tree
Hide file tree
Showing 3 changed files with 132 additions and 0 deletions.
16 changes: 16 additions & 0 deletions deploy.cmd
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
gp 'test'
git push heroku


heroku logs --tail

heroku

/app/.heroku/python/lib/python3.8/site-packages/pyhanlp/static/
下载 https://file.hankcs.com/hanlp/hanlp-1.8.4-release.zip 到 /app/.heroku/python/lib/python3.8/site-packages/pyhanlp/static/hanlp-1.8.4-release.zip
/app/.heroku/python/lib/python3.8/site-packages/pyhanlp/static/hanlp-1.8.4-release.zip

wget -o data-for-1.8.4.zip https://file.hankcs.com/hanlp/data-for-1.7.5.zip

wget -o data-for-1.8.4.zip http://software.haokeniu.com/data-for-1.7.5.zip
data-for-1.8.4.zip
79 changes: 79 additions & 0 deletions main.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
# -*- coding: utf-8 -*-
import os
import sys

import uvicorn
from apps.base.hello import hello, logger
from apps.base.conf import conf, LogLevel
from apps.route import create_app

root_path = os.getcwd()
sys.path.append(root_path)

abs_path = ""
if getattr(sys, 'frozen', False):
abs_path = os.path.dirname(os.path.abspath(sys.executable))
elif __file__:
abs_path = os.path.dirname(os.path.abspath("travelgpt"))

app = create_app()
if __name__ == "__main__":
log_config = {
"version": 1,
"disable_existing_loggers": "false",
"formatters": {
"default": {
"()": "uvicorn.logging.DefaultFormatter",
"fmt": "%(levelprefix)s %(message)s"
},
"access": {
"()": "uvicorn.logging.AccessFormatter",
"fmt": "%(asctime)s | %(levelprefix)s |%(client_addr)s - \"%(request_line)s\" %(status_code)s"
}
},
"handlers": {
"default": {
"formatter": "default",
"class": "logging.StreamHandler",
"stream": "ext://sys.stderr"
},
"access": {
"formatter": "access",
"class": "logging.StreamHandler",
"stream": "ext://sys.stdout"
}
},
"loggers": {
"uvicorn": {
"handlers": [
"default"
],
"level": "DEBUG"
},
"uvicorn.error": {
"level": "DEBUG"
},
"uvicorn.access": {
"handlers": [
"access"
],
"level": "DEBUG",
"propagate": "false"
}, "sqlalchemy.engine": {
"level": "DEBUG"
}
}
}
try:
name_app = os.path.basename(__file__)[0:-3]
print("App Directory:::::", os.getcwd())
hello()
uvicorn.run(app=f'{name_app}:app',
host=conf.host,
port=conf.port,
reload=False,
log_level=LogLevel.lower(),
log_config=log_config
)
except Exception as e:
logger.exception("Service Internal Error!", e)
37 changes: 37 additions & 0 deletions main.spec
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
# -*- mode: python ; coding: utf-8 -*-

a = Analysis(
['main.py'],
pathex=[],
binaries=[],
datas=[],
hiddenimports=[],
hookspath=[],
hooksconfig={},
runtime_hooks=[],
excludes=[],
noarchive=False,
optimize=0,
)
pyz = PYZ(a.pure)

exe = EXE(
pyz,
a.scripts,
a.binaries,
a.datas,
[],
name='main',
debug=False,
bootloader_ignore_signals=False,
strip=False,
upx=True,
upx_exclude=[],
runtime_tmpdir=None,
console=True,
disable_windowed_traceback=False,
argv_emulation=False,
target_arch=None,
codesign_identity=None,
entitlements_file=None,
)

0 comments on commit 1e94223

Please sign in to comment.