I'm trying to implement a scipt on OpenShift, which works to bypass a very basic firewall in my college.
The aim is that I add the OpenShift address to the tracker list in any torrent I am running.
The client requests the script for peers.
The script accepts the peer list request and then asks for the list itself from a valid tracker. For testing purposes I have hardcoded this into the script as the tracker works for the test torrent without the firewall.
The response is passed back to the torrent client on my computer.
MyPC <==> Openshift <==> Tracker
This code is not working for some reason. I followed the flask quick start guide and the OpenShift getting started guide .
I am new to networking so please help me out.
This is the routes.py file:
#!/usr/bin/python
import os,urllib2
from flask import Flask
from flask import request
app=Flask(__name__)
app.config['PROPAGATE_EXCEPTIONS']=True
#app.route('/announce/')
def tormirror_test():
q=request.query_string
u=urllib2.urlopen("http://exodus.desync.com:6969/announce?"+str(q))
return u
#app.route("/<name>")
def insulter(name):
return "this is a test code====="+name
if __name__ == "__main__":
app.run()
I think part of it is that your university may be blocking the connection back to your computer from OpenShift. My guess is your university blocks incoming connections on port 6969
Just putting it here so you can mark it answered
Related
NOT : I only have rcon password
I want to retrieve the logs on the csgo server, but I couldn't do it.
I can use c# nodejs and python
I created a project in replit using python and flask and with logaddress_add_http.I added the link of this project to the csgo server and it worked, but I could not figure out how to get the logs by adding the ip of my own computer with the logaddress_add to the csgo server.
Please help me, I couldn't find any sources about this
log on
logaddress_add_http "https://CSGO.synx12.repl.co"
My Code:
from flask import Flask,request
app=Flask(__name__)
#app.route("/",methods=["GET","POST"])
def index():
if(request.method=="GET"):
return "GET"
elif(request.method=="POST"):
data=request.get_data()
print(data)
return f"Data : {data}"
if(__name__=="__main__"):
app.run(host="0.0.0.0",port=8080)
I'm sending a message to the server with rcon
And Result
here logaddress_add_http works fine but I couldn't get logaddress_add to work at all
I want your help for this.
Hello Fellow Slack Bot Enthusiasts.
It's my first time to start setting up a Slack Bot (and I don't have a lot of dev experience, so I wanted to inquire!) .
For this, I used python and Slack bolt.
Background
I was trying to setup my Amazon EC2 Web Instance's Load Balancer to accept slack events from my Workspace. In the below photo, I am now able to have my Endpoint URL Verified in the Slack bot.
Next, I am trying to follow the instructions listed in the Slack Bolt homepage that told me to create the app.py test file. So I followed through on the instructions and ensured that I subscribed to below events:
app_home_opened
message.channels
message.groups
message.im
Then I created the sample app.py file from the article, that was supposed to handle the app_home_opened event.
Now I tried to run the application in my command line (I added the section for #app.event(app_home_opened), and all the other required events ), and I tried to trigger the app_home_opened, message.channels, message.im events, by opening the home page of my bot and by dm-ing the bot and inviting it to a channel and trying to talk to it - but I don't seem to be receiving any payload in the back-end.
I wanted to inquire about the "Verified" notification from the Slack Bot. Does this ensure that the connection between my chatbot code and the server are actually linked?
In addition, I wanted to inquire about ways to test this so that I can ensure that the connection is actually working as expected.
If you could share some thoughts about what I can do to test the communication, it would be much appreciated. Thank you!
Summary
TLDR:
Problem: My chatbot is not receiving any payload from Slack.
Expected: I think there should be some interaction saying HTTP / 200 response to indicate that it is OK, etc.
Actual: The chatbot just remains the same saying "⚡Bolt App is Running"
What I've tried:
Reinstalling the application to ensure that all my changes were saved and were reflected properly in my Slack Environment
Testing the communication by curling through to the URL (it responded with challenge parameter), so I thought that it was OK
Testing the communication by entering some text via DM / channel communication, and opening the homepage.
Sample Code:
import os
# Use the package we installed
from slack_bolt import App
# Initializes your app with your bot token and signing secret
app = App(
token=os.environ.get("SLACK_BOT_TOKEN"),
signing_secret=os.environ.get("SLACK_SIGNING_SECRET")
)
# Add functionality here
# #app.event("app_home_opened") ...
# added some of the code from the guide here and the other #app.events ("")
# Start your app
if __name__ == "__main__":
app.start(port=int(os.environ.get("PORT", 3000)))
slack_bolt, for some reason that escapes me, does not seem to create the event handler endpoint (/slack/events) and instead seems to prefer running the application in socket mode. It may still be worth looking into socket mode (see SocketModeHandler) but this example from slack_bolt's github repo ended up getting me to my solution: https://github.com/slackapi/bolt-python/blob/main/examples/flask/app.py
The short-ish version is you have to utilize slack_bolts's flask adapter to create a SlackRequestHandler then create a flask app, define the slack events endpoint (/slack/events) for the flask app, and pass the result to the bolt SlackRequestHandler (Events Endpoint -> Flask -> SlackRequestHandler -> Bolt):
import os
from flask import Flask, request
from slack_bolt import App
from slack_bolt.adapter.flask import SlackRequestHandler
bolt_app = App(
token=os.environ.get("SLACK_BOT_TOKEN"),
signing_secret=os.environ.get("SLACK_SIGNING_SECRET")
)
flask_app = Flask(__name__)
handler = SlackRequestHandler(bolt_app)
# Add functionality here
# #bolt_app.event("app_home_opened") ...
# added some of the code from the guide here and the other #bolt_app.events ("")
#flask_app.route("/slack/events", methods=["POST"])
def slack_events():
return handler.handle(request)
if __name__ == "__main__":
flask_app.run()
Hope this helps, cheers!
Basically I just booted up an older script that I made 1-2 months ago and which worked perfectly at the time, but now when I try to connect to the ngrok tunnel i get a 404 and a "Tunnel xxxx not found"
I have a non-paying user, which didn't use to be a problem and I cant see anywhere that they changed their terms of service and I can find the tunnel on the dashboard but not connect, any idea what is wrong and if they changed something?
I just booted an old super simple test script which also doesn't work, I can see the tunnel but it returns "Funnel xxxx not found" and server 404:
from flask import Flask
from flask_ngrok import run_with_ngrok
app = Flask(__name__)
run_with_ngrok(app) #starts ngrok when the app is run
#app.route("/")
def home():
return "<h1>Running Flask on Google Colab!</h1>"
app.run()
This question already has answers here:
Are a WSGI server and HTTP server required to serve a Flask app?
(3 answers)
Closed 3 years ago.
I have made an flask API which would take input directory as input parameter by get http request. It is working fine on port 5000 on the local machine.
Now I want that working api to run on a web server so that I can use it over internet. I tried apache 2 server to do the work but it wasn't successful.
# API
app = Flask(__name__)
#app.route('/')
def home():
return "HOME PAGE LOADED"
#app.route('/runDocumentManager', methods=["GET"])
def runDocumentManager():
# pdf path
file = request.args.get('input_path')
.
.
.
if __name__ == '__main__':
app.run()
Once you start your website it will be hosted on localhost:5000
So you want to make it host on your network first. Do so with:
app.run(host="0.0.0.0")
This will make your app run on your local network.
Then you will need to portforward it on your router. This is so that if someone types in your ip then it will send them to your router.
There you want your router to route it to your machine's server.
So if someone connects to (Your IP):5000 then it will place them on (192.168.0.X):5000 (aka. The server python webserver you are running). I highly recomend googling on how to portforward as it differs slightly on different routers
Usualy you can find it at either:
https://192.168.0.1
https://192.168.1.1
https://192.168.2.1
You might be required to type in the password and username which usualy is "admin" for both but may be different depending on your ISP. You can check that online as well.
I am using a web service that will send a url callback when a particular external event happens (that service is monitoring it 24-7)
I need to have a python script running (locally on my own computer) and waiting (possibly just looping) to receive that callback and then do something with the data.
How do I do this? Do I need to have a webserver running? Where do I look for the data? I am pretty experienced with python, but not much in the use of HTTP and other web related things.
I have looked at other stackoverflow posts but they all seem to presume some prior knowledge.... I need the basics!
Here is a simple server using Bottle Microframework .
from bottle import Bottle, run, route, request
app = Bottle()
#app.route('/listener')
def my_listener():
data = request.query.your_data
#do_something_with_data(data)
return data
run(app, host="0.0.0.0", port=8080)
You can send data to server requesting http://sever_ip:8080/listener?your_data=some_data
Look into setting up a Flask server that will run in the background and listen for the callback request