Skip to content

Commit

Permalink
publish to pipy
Browse files Browse the repository at this point in the history
  • Loading branch information
rafa0128 committed Aug 3, 2023
1 parent 96c0fb9 commit 680bf26
Show file tree
Hide file tree
Showing 8 changed files with 62 additions and 19 deletions.
4 changes: 3 additions & 1 deletion MANIFEST.in
Original file line number Diff line number Diff line change
@@ -1,2 +1,4 @@
recursive-include webmeter/static *
recursive-include webmeter/templates *
recursive-include webmeter/templates *
recursive-include webmeter/public *
recursive-include webmeter/view *
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
# webmeter
A web performance tool based on jmeter.

A web api-performance tool based on jmeter.
3 changes: 1 addition & 2 deletions __main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,11 @@ def checkPyVer():
versions = platform.python_version().split('.')
if int(versions[0]) < 3 or int(versions[1]) < 10:
logger.error('python version must be 3.10+ ,your python version is {}'.format(platform.python_version()))
# logger.info('https://github.com/smart-test-ti/SoloX/blob/master/README.md#requirements')
return False
return True

if __name__ == '__main__':
check = checkPyVer()
if check:
from webmeter.web import main
from webmeter.main import main
fire.Fire(main)
2 changes: 1 addition & 1 deletion setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,4 @@ classifier =

[entry_points]
console_scripts =
solox = webmeter.__main__:main
webmeter = webmeter.__main__:main
3 changes: 1 addition & 2 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,7 @@
long_description = fh.read()

setuptools.setup(
install_requires=['fastapi','uvicorn', 'requests', 'logzero', 'fire',
'tqdm', 'xlwt','pyfiglet','psutil','opencv-python'],
install_requires=['fastapi','uvicorn', 'requests', 'logzero', 'fire','pyfiglet','psutil'],
version='1.0.0',
long_description=long_description,
long_description_content_type="text/markdown",
Expand Down
43 changes: 31 additions & 12 deletions webmeter/main.py
Original file line number Diff line number Diff line change
@@ -1,17 +1,36 @@
import uvicorn
from fastapi import FastAPI, Request
from fastapi.responses import HTMLResponse
from fastapi.templating import Jinja2Templates
from public.utils import utils
import os
from fastapi import FastAPI
from webmeter.view import page,api
from webmeter.public.utils import utils
import requests
import webbrowser
import multiprocessing

app = FastAPI(debug=True)
STATICPATH = os.path.dirname(os.path.realpath(__file__))
templates = Jinja2Templates(directory=os.path.join(STATICPATH, 'templates'))
app.include_router(page.router)
app.include_router(api.router)


@app.get("/plan", response_class=HTMLResponse)
async def index(request: Request):
return templates.TemplateResponse("index.html", {"request": request})
if __name__ == "__main__":
uvicorn.run("main:app", host=utils.local_ip(), port=6006, reload=False)
def status(host: str, port: int):
r = requests.get('http://{}:{}/plan'.format(host, port), timeout=2.0)
flag = (True, False)[r.status_code == 200]
return flag

def start(host: str, port: int):
uvicorn.run("main:app", host=host, port=port, reload=False)

def open(host: str, port: int):
flag = True
while flag:
flag = status(host, port)
webbrowser.open('http://{}:{}/plan'.format(host, port), new=2)

def main(host=utils.local_ip(), port=6006):
pool = multiprocessing.Pool(processes=2)
pool.apply_async(start, (host, port))
pool.apply_async(open, (host, port))
pool.close()
pool.join()

# if __name__ == "__main__":
# main()
9 changes: 9 additions & 0 deletions webmeter/view/api.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
from fastapi import APIRouter

router = APIRouter()


@router.get("/api/language")
async def language():
response = {'status':1}
return response
14 changes: 14 additions & 0 deletions webmeter/view/page.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
from fastapi import Request
from fastapi.responses import HTMLResponse
from fastapi.templating import Jinja2Templates
from fastapi import APIRouter
import os

router = APIRouter()

STATICPATH = os.path.dirname(os.path.realpath(__file__))
templates = Jinja2Templates(directory=os.path.join(STATICPATH, '..', 'templates'))

@router.get("/plan", response_class=HTMLResponse)
async def index(request: Request):
return templates.TemplateResponse("index.html", {"request": request})

0 comments on commit 680bf26

Please sign in to comment.