Skip to content

Commit 9630cd8

Browse files
committed
Initial Commit
0 parents  commit 9630cd8

File tree

7 files changed

+148
-0
lines changed

7 files changed

+148
-0
lines changed

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
**/venv
2+
**/.idea
3+
**/__pycache__

LICENSE

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MIT License
2+
3+
Copyright (c) 2020 DALJEET SINGH CHHABRA
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

README.md

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
# Screen Caster
2+
3+
Project your computer's screen in your network to unlimited number of devices.
4+
5+
For global screen sharing, configure the router to forward requests on ```port:6999``` to your device in the local network.
6+
7+
# Usage:
8+
###### Using source code:
9+
Install the requirements for the code
10+
11+
$>cd <WORKING DIRECTORY>
12+
$>pip install -r requirements.txt
13+
14+
Running the Screen Caster
15+
16+
$>python app.py
17+
18+
###### Windows 10 users
19+
Head to releases section or dist folder to download the executable for windows.

app.py

Lines changed: 87 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,87 @@
1+
from flask import Flask, Response, render_template
2+
from io import BytesIO
3+
from PIL import ImageGrab
4+
import logging
5+
import os
6+
import sys
7+
import ifaddr
8+
import re
9+
10+
base_dir = '.'
11+
if hasattr(sys, '_MEIPASS'):
12+
base_dir = os.path.join(sys._MEIPASS)
13+
14+
app = Flask(__name__,
15+
static_folder=os.path.join(base_dir, 'static'),
16+
template_folder=os.path.join(base_dir, 'templates'))
17+
18+
19+
@app.route('/')
20+
def index():
21+
return render_template('index.html')
22+
23+
24+
@app.route('/feed')
25+
def video_feed():
26+
return Response(gen(), mimetype='multipart/x-mixed-replace; boundary=frame')
27+
28+
29+
def gen():
30+
while True:
31+
img_buffer = BytesIO()
32+
ImageGrab.grab().save(img_buffer, 'JPEG', quality=50)
33+
img_buffer.seek(0)
34+
yield (b'--frame\r\n'
35+
b'Content-Type: image/jpg\r\n\r\n' + img_buffer.read() + b'\r\n\r\n')
36+
37+
38+
if __name__ == '__main__':
39+
def get_v4(ip, adapter):
40+
if re.match(r"^((25[0-5]|(2[0-4]|1[0-9]|[1-9]|)[0-9])(\.(?!$)|$)){4}$", ip):
41+
print(f'• Sharing screen on ip => http://{ip}:6999 \tof "{adapter}"')
42+
43+
44+
cli = sys.modules['flask.cli']
45+
cli.show_server_banner = lambda *x: None
46+
cli = lambda *x: None
47+
log = logging.getLogger('werkzeug')
48+
log.setLevel(logging.ERROR)
49+
50+
APP_TITLE = """
51+
52+
53+
.----------------. .----------------. .----------------. .----------------. .----------------. .-----------------.
54+
| .--------------. | .--------------. | .--------------. | .--------------. | .--------------. | .--------------. |
55+
| | _______ | | | ______ | | | _______ | | | _________ | | | _________ | | | ____ _____ | |
56+
| | / ___ | | | | .' ___ | | | | |_ __ \ | | | |_ ___ | | | | |_ ___ | | | ||_ \|_ _| | |
57+
| | | (__ \_| | | | / .' \_| | | | | |__) | | | | | |_ \_| | | | | |_ \_| | | | | \ | | | |
58+
| | '.___`-. | | | | | | | | | __ / | | | | _| _ | | | | _| _ | | | | |\ \| | | |
59+
| | |`\____) | | | | \ `.___.'\ | | | _| | \ \_ | | | _| |___/ | | | | _| |___/ | | | | _| |_\ |_ | |
60+
| | |_______.' | | | `._____.' | | | |____| |___| | | | |_________| | | | |_________| | | ||_____|\____| | |
61+
| | | | | | | | | | | | | | | | | | |
62+
| '--------------' | '--------------' | '--------------' | '--------------' | '--------------' | '--------------' |
63+
'----------------' '----------------' '----------------' '----------------' '----------------' '----------------'
64+
.----------------. .----------------. .----------------. .----------------. .----------------. .----------------.
65+
| .--------------. | .--------------. | .--------------. | .--------------. | .--------------. | .--------------. |
66+
| | ______ | | | __ | | | _______ | | | _________ | | | _________ | | | _______ | |
67+
| | .' ___ | | | | / \ | | | / ___ | | | | | _ _ | | | | |_ ___ | | | | |_ __ \ | |
68+
| | / .' \_| | | | / /\ \ | | | | (__ \_| | | | |_/ | | \_| | | | | |_ \_| | | | | |__) | | |
69+
| | | | | | | / ____ \ | | | '.___`-. | | | | | | | | | _| _ | | | | __ / | |
70+
| | \ `.___.'\ | | | _/ / \ \_ | | | |`\____) | | | | _| |_ | | | _| |___/ | | | | _| | \ \_ | |
71+
| | `._____.' | | ||____| |____|| | | |_______.' | | | |_____| | | | |_________| | | | |____| |___| | |
72+
| | | | | | | | | | | | | | | | | | |
73+
| '--------------' | '--------------' | '--------------' | '--------------' | '--------------' | '--------------' |
74+
'----------------' '----------------' '----------------' '----------------' '----------------' '----------------'
75+
76+
77+
78+
79+
"""
80+
print(APP_TITLE)
81+
network_adapters = ifaddr.get_adapters()
82+
83+
for adapter in network_adapters:
84+
for ip in adapter.ips:
85+
get_v4(str(ip.ip), str(adapter.nice_name))
86+
print('\n** (Press CTRL+C) to stop screen share')
87+
app.run(host='0.0.0.0', port=6999, debug=False)

dist/Caster.exe

9.5 MB
Binary file not shown.

requirements.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
Flask==1.1.1
2+
ifaddr==0.1.6
3+
Pillow==7.0.0

templates/index.html

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
<!DOCTYPE html>
2+
<html lang="en">
3+
<head>
4+
<meta charset="UTF-8">
5+
<title>Screen Caster</title>
6+
</head>
7+
8+
<body style="background-color: dimgray">
9+
<center><h1>Screen Caster</h1></center>
10+
<div id="content">
11+
<img src="/feed" id="feed" height="100%" width="100%" alt="Loading video feed...">
12+
</div>
13+
<h6>Made By: Daljeet Singh Chhabra</h6>
14+
</body>
15+
</html>

0 commit comments

Comments
 (0)