Issue
I have built a web app using flask and I won't be able to host it in a cloud server for the moment. I want to host it in my Windows 10 OS, and I'm not concerned about the app to have secure certificates since it is intended to be shown as prototype. Three files are enough to showcase the result of the app:
myapp.py
:
# This a Natural Language Processing app using a machine learning model
class Lingus:
def __init__(self, data):
self.text = data
def output(self):
return self.text+" - "+self.text+"\n"+self.text
Next, is an html file in the folder templates templates/my-form.html
:
<form method="POST">
<input name="text">
<input type="submit">
</form>
Finally, a python script using flask for the app called main.py
:
from flask import Flask, request, render_template
from myapp import Lingus
app = Flask(__name__)
@app.route('/')
def my_form():
return render_template('my-form.html')
@app.route('/', methods=['POST'])
def my_form_post():
text = request.form['text']
processed_text = text.upper()
result = Ling(text)
return result.output()
if __name__ == "__main__":
app.run(debug=True)
Again, the goal is to make this app accessible through any browser in the web (not locally), using Windows 10. I don't have experience in back-end development or network engineering but I think this is something which is technically possible.
PS: I don't need the app to have security certificates for clients.
Solution
v25 Solution in the question's comment worked perfectly. It avoided port forwarding, and it consisted of downloading ngrok and writing one line of code for the app to be hosted locally. You only have to download ngrok on a free account, and write ngrok http < PORT ON WHICH YOUR APP IS RUNNING >
. I was running my flask app on the port 5000, so for my case, I did run the app locally, opened ngrok.exe and wrote:
ngrok http 5000
And that's it. Now, I can show my app's prototype to anyone and give it for users to test it. However, the app address changes every 8 hours, you should upgrade your account to get a static address for your app.
Answered By - Samir Ahmane
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.