mirror of
https://github.com/laramies/theHarvester.git
synced 2024-09-20 07:16:31 +08:00
Add api restfulHarvest script to setup.py and fix a bug in the api to handle that
This commit is contained in:
parent
faf7b23af2
commit
ed4e5bcace
14
bin/restfulHarvest
Executable file
14
bin/restfulHarvest
Executable file
|
@ -0,0 +1,14 @@
|
|||
#!/usr/bin/env python3
|
||||
import uvicorn
|
||||
import argparse
|
||||
|
||||
parser = argparse.ArgumentParser()
|
||||
parser.add_argument('-H', '--host', default='127.0.0.1', help='IP address to listen on default is 127.0.0.1')
|
||||
parser.add_argument('-p', '--port', default=5000, help='Port to bind the web server to, default is 5000', type=int)
|
||||
parser.add_argument('-l', '--log-level', default='info', help='Set logging level, default is info but [critical|error|warning|info|debug|trace] can be set')
|
||||
parser.add_argument('-r', '--reload', default=False, help='Enable automatic reload used during development of the api', action='store_true')
|
||||
|
||||
args = parser.parse_args()
|
||||
|
||||
if __name__ == '__main__':
|
||||
uvicorn.run('theHarvester.lib.api.api:app', host=args.host, port=args.port, log_level=args.log_level, reload=args.reload)
|
3
setup.py
3
setup.py
|
@ -15,7 +15,8 @@
|
|||
url="https://github.com/laramies/theHarvester",
|
||||
packages=find_packages(exclude=['tests']),
|
||||
python_requires='>=3.7',
|
||||
scripts=['bin/theHarvester'],
|
||||
scripts=['bin/theHarvester',
|
||||
'bin/restfulHarvest'],
|
||||
|
||||
classifiers=[
|
||||
"Programming Language :: Python :: 3",
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
import argparse
|
||||
from typing import List
|
||||
|
||||
import os
|
||||
from fastapi import FastAPI, Header, Query, Request
|
||||
from fastapi.responses import HTMLResponse, ORJSONResponse
|
||||
from slowapi import Limiter, _rate_limit_exceeded_handler
|
||||
|
@ -17,7 +17,13 @@
|
|||
app.add_exception_handler(RateLimitExceeded, _rate_limit_exceeded_handler)
|
||||
|
||||
# This is where we will host files that arise if the user specifies a filename
|
||||
app.mount('/static', StaticFiles(directory='theHarvester/lib/api/static/'), name='static')
|
||||
try:
|
||||
app.mount('/static', StaticFiles(directory='theHarvester/lib/api/static/'), name='static')
|
||||
except RuntimeError:
|
||||
static_path = os.path.expanduser('~/.local/share/theHarvester/static/')
|
||||
if not os.path.isdir(static_path):
|
||||
os.makedirs(static_path)
|
||||
app.mount('/static', StaticFiles(directory='~/.local/share/theHarvester/static/'), name='static')
|
||||
|
||||
|
||||
@app.get('/', response_class=HTMLResponse)
|
||||
|
|
Loading…
Reference in a new issue