Question

Hi I'm trying to write a code for a web server in python with flask. This...

Hi I'm trying to write a code for a web server in python with flask. This is what I have so far

from flask import Flask     
app = Flask(__name__)
@app.route('/')             #first endpoint i.e. "http://localhost/"
def index():
    return 'hello'    #return data in string

if __name__ == '__main__':
  app.run(debug=True)

After running the code, I'm given a address to the web with the text hello. The problem is that this only works with my computer that is running the code. If I try to enter this address into my phone's browser it will show up as connection refused. How do I fix this so that I can get a Python Web Server with a address that will show 'hello' on any device.

0 0
Add a comment Improve this question Transcribed image text
Answer #1

Flask runs on a Local Server on a port given port. The reason you cannot open it in your mobile browser is because it is not deployed on the web, in order to display that code on your mobile device you have to be connected on the same network i.e the machine you are running the code on (in which you made that local server) and that device you want that code to display in.

Add a comment
Know the answer?
Add Answer to:
Hi I'm trying to write a code for a web server in python with flask. This...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • Project Description In this project, you will be developing a multithreaded Web server and a simple...

    Project Description In this project, you will be developing a multithreaded Web server and a simple web client. The Web server and Web client communicate using a text-based protocol called HTTP (Hypertext Transfer Protocol). Requirements for the Web server The server is able to handle multiple requests concurrently. This means the implementation is multithreaded. In the main thread, the server listens to a specified port, e.g., 8080. Upon receiving an HTTP request, the server sets up a TCP connection to...

  • This is Python 2.7 I'm trying to make my output look like this: ['weather: (55, 75,...

    This is Python 2.7 I'm trying to make my output look like this: ['weather: (55, 75, 80)', 'windspeed: 10', 'humidity: (35, 40)'] This is what it looks like now ['weather: (55, 75, 80)'] ['windspeed: 10'] ['humidity: (35, 40)'] ________________________________________________________________________________________________________________________________ This is how my code looks: def weather_strings(dictionary): 1_list = [ ] for key in dictionary.keys(): the_keys = str(key) val = str(dictionary[key]) print 1_list + [the_keys + ': ' + val] def main(): """This function prints the above functions""" test_dict =...

  • AND logic gate simulation in Python: Please fix the code below so that it efficiently performs...

    AND logic gate simulation in Python: Please fix the code below so that it efficiently performs the operation of the AND logic gate in Python. (Leave comments in the edited code about what you changed) #if both values are 1, return true, other wise return false print ("Logic Gate Simulation: AND gate") def AND(x, y):     if x == True and y == True:         return True        else:         return False    def main():     x = bool(input("Please...

  • Me and my friend are developing a web-app in Python + Flask + PostgreSQL. We have...

    Me and my friend are developing a web-app in Python + Flask + PostgreSQL. We have been working on it for the past few months and have developed a lot of schema/use-cases specific to Python + Flask + PostgreSQL. Now, all of a sudden, we plan to move to another NoSQL database (Neo4j) because it somehow fits better to what the core of our web-app is going to be. Python supports Neo4j through embedded/rest api bindings, but uses a technology...

  • How do I make my code print out the text in the ServiceNotifier class? Python Code:...

    How do I make my code print out the text in the ServiceNotifier class? Python Code: class ServiceNotifier: #Subject responsible for notifying registered observer objects    Observer = [Email, SMS, Phone]       def attach(self):    #add new observer        Observer.append(insertnewobserverhere)    def dettach(self):    #remove an observer        Observer.pop(insertnewobserverhere)    def servicenotifier(self):        for observers in Observer:            print("Due to the forecast for tomorrow, all university and campus operations will be closed.")       ...

  • Hello, In Python, I am trying to create a function that will return the domain name...

    Hello, In Python, I am trying to create a function that will return the domain name from any inputted email address. For example, my input of [email protected] would return just the domainname. It needs to be done using regular expressions and the map function. I'm still stuck on trying to get the correct parameters for regular expression and also what is throwing it off. Thank you for your help! I am currently working with a list of different email addresses...

  • need help to complete the task: app.py is the Python server-side application. It includes a class...

    need help to complete the task: app.py is the Python server-side application. It includes a class for representing the list of albums. You need to complete the missing parts such that it loads data from the data/albums.txt and data/tracks.txt files. You can decide what internal data structure you want to use for storing the data. It is already implemented that a single instance of the Albums class is used, so that loading from the files happens only once (and not...

  • Help with Python code. Right now I'm creating a code in Python to create a GUI....

    Help with Python code. Right now I'm creating a code in Python to create a GUI. Here's my code: #All modules are built into Python so there is no need for any installation import tkinter from tkinter import Label from tkinter import Entry def calculatewages(): hours=float(nhours.get()) nsal=float(nwage.get()) wage=nsal*hours labelresult=Label(myGUI,text="Weekly Pay: $ %.2f" % wage).grid(row=7,column=2) return Tk = tkinter.Tk()    myGUI=Tk myGUI.geometry('400x200+100+200') myGUI.title('Pay Calculator') nwage=float() nhours=float() label1=Label(myGUI,text='Enter the number of hours worked for the week').grid(row=1, column=0) label2=Label(myGUI,text='Enter the pay rate').grid(row=2, column=0)...

  • Hi, I need some help finishing the last part of this Python 1 code. The last...

    Hi, I need some help finishing the last part of this Python 1 code. The last few functions are incomplete. Thank you. The instructions were: The program has three functions in it. I’ve written all of break_into_list_of_words()--DO NOT CHANGE THIS ONE. All it does is break the very long poem into a list of individual words. Some of what it's doing will not make much sense to you until we get to the strings chapter, and that's fine--that's part of...

  • ARDUINO Hi I'm trying to write a code for a personal project, but I haven't used...

    ARDUINO Hi I'm trying to write a code for a personal project, but I haven't used much arduino before. It's supposed to be a function where it takes in motor speed as an int and motor direction as a bool. The PWM is 8 bits. So it's supposed to be an asynchronous function where the blue is always at 50%, then it gets more green as it has a higher speed forward and more red as it has a higher...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT