diff --git a/main.py b/main.py
index aec96c5..718d0b5 100644
--- a/main.py
+++ b/main.py
@@ -1,37 +1,18 @@
-import socket
+from fastapi import FastAPI
-def generate_html_response(count):
- html_content = """
-
-
- Страница счетчика
-
-
- Счетчик: {}
-
-
- """.format(count)
- return html_content
-
-serv_sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
-serv_sock.bind(('0.0.0.0', 12345))
-serv_sock.listen(5)
+app = FastAPI()
count = 0
-while True:
- client_sock, client_addr = serv_sock.accept()
- data = client_sock.recv(1024)
- request = data.decode()
- print(request)
+@app.get("/count")
+async def get_count():
+ global count
+ count += 1
+ return {"count": count}
- if "GET /count" in request:
- count += 1
- html_response = generate_html_response(count)
- http_response = "HTTP/1.1 200 OK\r\nContent-Type: text/html; charset=utf-8\r\n" + html_response
- client_sock.sendall(http_response.encode())
- else:
- http_response = "HTTP/1.1 200 OK\r\nContent-Type: text/html; charset=utf-8\r\n "
- client_sock.sendall(http_response.encode())
-
- client_sock.close()
\ No newline at end of file
+@app.get("/")
+async def root():
+ return {"message": "Hello World"}
+if __name__ == "__main__":
+ import uvicorn
+ uvicorn.run(app, host="0.0.0.0", port=12345)