Hosting Python Twilio server online? - python

I'm trying to complete an iOS Swift app that send SMS with custom body. I found the following tutorial and it worked for me, however, it requires having a running python server. Is there any site that you recommend where I can host the python server and access it remotely through the web? Are there any alternatives for doing this by skipping the python server and directly sending an HTTP request from the app?
Note: This is in iOS 11 and Xcode 9 with latest version of Swift. I am also a beginner with HTTP requests and server stuff.

Your best bet is to host it through heroku (initially). the pricing structure is built on activity (great if you are testing and need hosting to be as inexpensive as possible), auto recognition of python code, and they give you a url that you can access remotely (i.e. someapp.heroku.com) that should allow you to access in your app.

Related

Running Django in IIS

I have a Python application that's that has been working correctly as backend for my website, up to now I have been running it using "python manage.py runserver IP:8000" in CMD. However I would like it to start using HTTPS, but when I try to access through my browser on https://IP:PORT I get the following error:
You're accessing the development server over HTTPS, but it only
supports HTTP.
The server I am running all of this is a Windows Center 2019 DataCenter, normally on a linux environment I would just use NGINX+GUNICORN.
I was browsing possible solutions and stumbled upon this, however I already am using IIS to host a website (My frontend), so I needed to figure out how to host several websites for the same IP, I have now found this.
Long story short, I configured the new IIS website for it to access my django, I then changed the hostname since both frontend and the new backend will using the same ip and ports (80, 443).
But now I have hit a spot where I'm confused due to my lack of experience in IIS and networking. I can't seem to understand how the request will go through to my Python-Django APP.
Something important to mention on how I access the Django APP in the past.
Lets say my front end is https://pr.app.com, whenever any request needed to be made to the backend. I would ask for said information in http://pr.app.com:8000/APIService/..../
This is how the binding for my frontend looks like
And this is the binding for the new backend where I changed the hostname as the second guide linked said
Any guidance or help would be most appreciated,
Thanks in advance
*Update
So I tried pausing my frontend website and used these bindings on the new backend website, I was able to get a screen of Django meaning it seems to be working or at least communicating.
Now I would need to have the hostname of the backend (pr.abcapi.com) somehow refer or redirect to the hostname of the frontend (pr.abc.com).
How could I achieve this?

What is the most efficient way to create an https endpoint for existing Teams chatbot (python)?

I've recently got a Teams chatbot working. The chatbot is written in Python and is based on code samples provided on the Microsoft Bot Builder GitHub (link below). As suggested in the code samples, I started off with using ngrok for testing. So the setup currently is like this:
When someone sends a message to the Bot, the message is routed to Azure Bot Service.
Asure Bot Service is configured to send traffic to an AWS EC2 instance which has ngrok running along with the python app. Ngrok endpoint: https://xyz.ngrok.io.
Python app on the EC2 instance responds back to the user (python app > ngrok > Azure Bot Service > Microsoft Teams).
The above setup works well but now I'd like to remove the ngrok intermediary. When I realize that Azure Bot Service only allows https endpoint and that my ngrok was doing the ssl. Looks like the code samples provided was from before Azure made it mandatory for Bot Service to only use https endpoint. Could anyone please advise what's the best way to move forward in my situation? I understand that re-architecture using api gateway/lambda would make it easier but I'd like to keep the current architecture for now. Is my only option to create certificates (which is new to me)? Appreciate any guidance here.
https://github.com/microsoft/BotBuilder-Samples/tree/main/samples/python/02.echo-bot
You can definitely remove ngrok, and it cetainly should be removed - it's only meant for local workstation development, and one of the main reasons is to support SSSL/TLS as httpS is -required- for bots. You'll need to spend some time figuring out how to get certificates working on your EC2, as a result, but it's probably really good experience as httpS is mandated for various things these days. Also, although I don't have any personal experience with EC2, these days I can't imagine it's hard to add certificates.

Communicate Android app with python Django web server

I am creating a mobile app, I want to access a web server that is implemented in Python Django. I found that there is Retrofit in android to communicate with a web server. My question is that whether I have to write Client REST API and Server REST API both.
As I am considering that I will write REST API using Retrofit (Client REST API).
And then write a REST API for my server in python Django (Server API).
I am really confused about what will be the way to communicate with my server that is developed in python Django. And up to what limit I have control on server i.e how much an android app can control(create a database in web server, perform CRUD operations)
Thanks!
Actually, it is quite simply, independent of the language of your server, basically if your server can respond with a json, you can use Retrofit2 and POST, GET, UPDATE, DELETE, etc...

Trying to use python on a server

I am using pythonanywhere.com and trying to run an app that I made for twitter that uses tweepy but it keeps saying connection refused or failed to send request. Is there any way to run a python app online easily that sends requests?
Pythonanywhere requires a premium account for web access.
You can create a limited account with one web app at your-username.pythonanywhere.com, restricted Internet access from your apps, low CPU/bandwidth. It works and it's a great way to get started!
Get a premium account:
$5/month
Run your Python code in the cloud from one web app and the console
A Python IDE in your browser with unlimited Python/bash consoles
One web app with free SSL at
your-username.pythonanywhere.com
Enough power to run a typical 50,000 hit/day website.
(more info)
3,000 CPU-seconds per day
(more info)
512MB disk space
That said, I'd just set it up locally if its for personal use and go from there.
You will need a server that has a public IP.
You have a few options here:
You can use a platform-as-a-service provider like Heroku or AWS Elastic Beanstalk.
You can get a server online on AWS, install your dependencies and use it instead.
As long as you keep your usage low, you can stay withing the free quotas for these services.

Do rest servers need to be hosted on a website or CMS?

I need to create a REST server of a python module/API of a BCI, so that the application can be accessed on my Drupal website. Will I need to create and host the REST server on a python-based website or CMS, so that it can be accessed by my Drupal website, or is the api and rest server uploaded and hosted directly on my web hosting server? If so, what is the simplest python CMS that for creating a REST server for a python module/API already available?
The beauty of REST is precisely that it doesn't matter where your API is, as long as its accessible from your Drupal server, or from the client if you have a javascript API client.
If it's a simple application and you have admin access to your Drupal server, there's nothing preventing you from hosting the Python webservice side-by-side. They may even share the same HTTP Server, like Apache or Nginx, although depending on your demands on each one it might be better to keep them separate.
If you're new to Python, the Flask framework is a decent option to write a simple REST-like API interfacing with a Python module.

Categories