-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.py
More file actions
164 lines (152 loc) · 7.13 KB
/
Copy pathmain.py
File metadata and controls
164 lines (152 loc) · 7.13 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
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
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
from os import environ
from flask import Flask, jsonify, render_template, request
from requests import post
app = Flask(__name__)
def get_info(replit_id):
out = (post(
"https://replit.com/graphql",
headers={
"Referer": "https://replit.com",
"X-Requested-With": "replit",
},
json={
"variables": {
"id": replit_id
},
"query":
"""
query Repl($id: String) {
repl(id: $id) {
... on Repl {
id
isProject
isPrivate
isStarred
title
slug
imageUrl
folderId
isRenamed
commentCount
likeCount
currentUserDidLike
templateCategory
wasPosted
wasPublished
layoutState
language
owner: user {
id
username
}
origin {
id
title
url
}
iconUrl
templateLabel
url
multiplayerInvites {
email
replId
type
}
rootOriginReplUrl
timeCreated
timeUpdated
isOwner
config {
isServer
gitRemoteUrl
domain
isVnc
doClone
}
pinnedToProfile
hostedUrl
hostedUrlDotty: hostedUrl(dotty: true)
hostedUrlDev: hostedUrl(dev: true)
hostedUrlNoCustom: hostedUrl(noCustomDomain: true)
currentUserPermissions {
changeTitle
changeDescription
changeImageUrl
changeIconUrl
changeTemplateLabel
changeLanguage
changeConfig
changePrivacy
star
move
delete
leaveMultiplayer
editMultiplayers
viewHistory
containerAttach
containerWrite
changeAlwaysOn
linkDomain
changeCommentSettings
inviteGuests
publish
fork
}
isProjectFork
isModelSolution
isModelSolutionFork
workspaceCta
publicForkCount
runCount
isAlwaysOn
isBoosted
tags {
id
isOfficial
}
lastPublishedAt
multiplayers {
username
}
nixedLanguage
publishedAs
description(plainText: true)
markdownDescription: description(plainText: false)
templateInfo {
label
iconUrl
}
domains {
domain
state
}
replViewSettings {
id
defaultView
replFile
replImage
}
}
}
}
""",
},
).json())
return ((out.get("data", out) or out).get("repl", out)) if out else None
@app.route('/')
def index():
return render_template('index.html')
@app.route('/get')
def repl_info():
replit_id = request.args.get('replit_id') or environ.get('REPL_ID')
if not replit_id:
return jsonify({'error': 'replit_id is required'}), 400
try:
info = get_info(replit_id)
if isinstance(info, dict) and request.args.get('title') is not None:
info = info.get("title", "")
return info if isinstance(info, str) else jsonify(info)
except Exception as e:
return jsonify({"error": str(e)}), 500
if __name__ == '__main__':
app.run(host='0.0.0.0', port=8080, debug=True)