testing
Browse files- Dockerfile +13 -0
- app.py +10 -0
- requirements.txt +4 -0
- take_ss.py +11 -0
Dockerfile
ADDED
@@ -0,0 +1,13 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
FROM python:3.9
|
2 |
+
|
3 |
+
RUN useradd -m -u 1000 user
|
4 |
+
|
5 |
+
WORKDIR /app
|
6 |
+
|
7 |
+
COPY --chown=user ./requirements.txt requirements.txt
|
8 |
+
|
9 |
+
RUN pip install --no-cache-dir --upgrade -r requirements.txt
|
10 |
+
|
11 |
+
COPY --chown=user . /app
|
12 |
+
|
13 |
+
CMD ["uvicorn", "app:app", "--host", "0.0.0.0", "--port", "7860"]
|
app.py
ADDED
@@ -0,0 +1,10 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
from fastapi import FastAPI
|
2 |
+
from take_ss import take_screenshot
|
3 |
+
import os
|
4 |
+
|
5 |
+
app = FastAPI()
|
6 |
+
pwd = os.getcwd()
|
7 |
+
|
8 |
+
@app.get("/")
|
9 |
+
def greet_json():
|
10 |
+
return {"Sonuc": take_screenshot}
|
requirements.txt
ADDED
@@ -0,0 +1,4 @@
|
|
|
|
|
|
|
|
|
|
|
1 |
+
|
2 |
+
fastapi
|
3 |
+
uvicorn[standard]
|
4 |
+
playwright
|
take_ss.py
ADDED
@@ -0,0 +1,11 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
from playwright.sync_api import sync_playwright
|
2 |
+
|
3 |
+
def take_screenshot(url, path):
|
4 |
+
with sync_playwright() as p:
|
5 |
+
browser = p.firefox.launch()
|
6 |
+
page = browser.new_page()
|
7 |
+
page.goto(url)
|
8 |
+
page.screenshot(path=path)
|
9 |
+
browser.close()
|
10 |
+
|
11 |
+
|