-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
8 changed files
with
62 additions
and
19 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 * |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -14,4 +14,4 @@ classifier = | |
|
||
[entry_points] | ||
console_scripts = | ||
solox = webmeter.__main__:main | ||
webmeter = webmeter.__main__:main |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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}) |