Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update app.py #1

Open
wants to merge 11 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 33 additions & 0 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
{
"name": "Python 3",
// Or use a Dockerfile or Docker Compose file. More info: https://containers.dev/guide/dockerfile
"image": "mcr.microsoft.com/devcontainers/python:1-3.11-bullseye",
"customizations": {
"codespaces": {
"openFiles": [
"README.md",
"app.py"
]
},
"vscode": {
"settings": {},
"extensions": [
"ms-python.python",
"ms-python.vscode-pylance"
]
}
},
"updateContentCommand": "[ -f packages.txt ] && sudo apt update && sudo apt upgrade -y && sudo xargs apt install -y <packages.txt; [ -f requirements.txt ] && pip3 install --user -r requirements.txt; pip3 install --user streamlit; echo '✅ Packages installed and Requirements met'",
"postAttachCommand": {
"server": "streamlit run app.py --server.enableCORS false --server.enableXsrfProtection false"
},
"portsAttributes": {
"8501": {
"label": "Application",
"onAutoForward": "openPreview"
}
},
"forwardPorts": [
8501
]
}
15 changes: 6 additions & 9 deletions app.py
Original file line number Diff line number Diff line change
@@ -2,26 +2,24 @@
from flask_cors import CORS
import requests
import re
from werkzeug.middleware.proxy_fix import ProxyFix

app = Flask(__name__)
CORS(app) # This will enable CORS for all routes in your Flask app
CORS(app, resources={r"/*": {"origins": "*"}})
app.wsgi_app = ProxyFix(app.wsgi_app, x_for=1, x_host=1)

pattern = r'\/h\/list'
hostM = 'http://172.232.43.70'
hostM = 'https://yourdomain.com'


@app.route('/')
def home():
return 'ehhhh'


@app.route('/fetch/')
def fetch():
url = request.args.get('url')
host = request.host
splitedh = host.split(':')
port = splitedh[1]
host = hostM + ':' + port + '/fetch?url='
host = hostM + '/fetch?url='
if url:
match_result = bool(re.search(pattern, url))
url = url.replace(' ', '')
@@ -49,6 +47,5 @@ def fetch():
else:
return 'what the fuck specify url pls '


if __name__ == '__main__':
app.run(debug=True)
app.run(debug=True, host='0.0.0.0', port=5000)
4 changes: 2 additions & 2 deletions vercel.json
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
{
"version":2,
"builds":[
{"'src":"app.py","use":"@vercel/python"}
{"src":"app.py","use":"@vercel/python"}
],
"routes":[
{"src":"/(.*)","dest":"app.py"}
]
}
}