feat(schema): add method & code columns

This commit is contained in:
DarkCat09 2024-07-02 18:51:00 +04:00
parent 524f9fd3c9
commit 74e6771fd3
Signed by: DarkCat09
GPG key ID: 0A26CD5B3345D6E3

View file

@ -16,7 +16,9 @@ with db as conn:
conn.executescript(''' conn.executescript('''
create table if not exists data ( create table if not exists data (
id integer primary key, id integer primary key,
url text not null method text not null default "GET",
url text not null,
code integer default null
); );
''') ''')
@ -30,7 +32,11 @@ def response(flow: HTTPFlow) -> None:
return return
uid: int = 0 uid: int = 0
with db as conn: with db as conn:
cur = conn.execute('insert into data (url) values (?) returning id', (url,)) code = flow.response.status_code
cur = conn.execute(
'insert into data (method, url, code) values (?, ?, ?) returning id',
(req.method, url, code if code != 200 else None),
)
uid = cur.fetchone()[0] uid = cur.fetchone()[0]
path = os.path.join(storage, f'{uid}') path = os.path.join(storage, f'{uid}')
if not os.path.exists(path): if not os.path.exists(path):