Update app.py
Browse files427 unmodified lines4284294304314324334344354364374384394404414424434444454464475 unmodified lines45345445545645745828 unmodified lines48748848949049149249349449524 unmodified lines520521522523524525117 unmodified lines643644645646647648649650651652653654655427 unmodified linesexcept HTTPException as e:return e@app.post("/simulate")async def simulate(urls: str = Form(...), platform: str = Form(...), count: int = Form(...), delay: int = Form(...), parallel_processes: int = Form(...)):try:if os.getenv(f'{platform.upper()}_USER') and os.getenv(f'{platform.upper()}_PASSWORD'):session = authenticate(os.getenv(f'{platform.upper()}_USER'), os.getenv(f'{platform.upper()}_PASSWORD'), platform)for index, url in enumerate(urls.split("\n")):try:video_id = extract_video_id(url, platform)proxy = get_random_proxy()if not proxy:print("No proxy available.")returnfake = Faker()fake_ipv4 = fake.ipv4()headers = {5 unmodified linesproxies = {"http": f"http://{proxy}"}if platform == "instagram":view_url = f"https://www.instagram.com/reel/{video_id}"response = session.get(view_url, headers=headers, proxies=proxies)28 unmodified linesembed_link = Noneembed_link_with_start = Noneprint(f"Simulation started for URL {index+1}: {url}")print(f"Preview: {embed_link_with_start}")return HTMLResponse(f"""<!DOCTYPE html><html>24 unmodified linessetInterval(updateViews, 5000); // Actualiza las visitas cada 5 segundos</script><p>Views: <span id="views-counter">0</span></p></body></html>""")117 unmodified linesdef rand(min, max):return random.randint(min, max)total_views = 0@app.get("/views")def get_views():global total_viewsreturn str(total_views)if __name__ == "__main__":import uvicornuvicorn.run(app, host="0.0.0.0", port=7860)427 unmodified lines4284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584595 unmodified lines46546646746846947047128 unmodified lines50050150250350450550650750850951051151251351424 unmodified lines539540541542543544545117 unmodified lines663664665666667668427 unmodified linesexcept HTTPException as e:return etotal_views = 0@app.get("/views")def get_views():global total_viewsreturn str(total_views)@app.post("/simulate")async def simulate(urls: str = Form(...), platform: str = Form(...), count: int = Form(...), delay: int = Form(...), parallel_processes: int = Form(...)):try:if os.getenv(f'{platform.upper()}_USER') and os.getenv(f'{platform.upper()}_PASSWORD'):session = authenticate(os.getenv(f'{platform.upper()}_USER'), os.getenv(f'{platform.upper()}_PASSWORD'), platform)urls = urls.split("\n")total_urls = len(urls)current_url = 0for index, url in enumerate(urls):try:video_id = extract_video_id(url, platform)proxy = get_random_proxy()if not proxy:print("No proxy available.")returnfake = Faker()fake_ipv4 = fake.ipv4()headers = {5 unmodified linesproxies = {"http": f"http://{proxy}"}if platform == "instagram":view_url = f"https://www.instagram.com/reel/{video_id}"response = session.get(view_url, headers=headers, proxies=proxies)28 unmodified linesembed_link = Noneembed_link_with_start = Noneglobal total_viewstotal_views += 1print(f"Simulation started for URL {index+1}: {url}")print(f"Preview: {embed_link_with_start}")current_url += 1progress = (current_url / total_urls) * 100return HTMLResponse(f"""<!DOCTYPE html><html>24 unmodified linessetInterval(updateViews, 5000); // Actualiza las visitas cada 5 segundos</script><p>Views: <span id="views-counter">0</span></p><p>Progress: {progress}%</p></body></html>""")117 unmodified linesdef rand(min, max):return random.randint(min, max)if __name__ == "__main__":import uvicornuvicorn.run(app, host="0.0.0.0", port=7860)
app.py+23-10