python - Hosting a simple script with user inputs on PythonAnywhere -


i beginner in python, , trying host python script on pythonanywhere, fun. took code codecadamy exercise make python piglatin translator, requires user inputs. having trouble getting host actual application part. here current code.

import os flask import flask app=flask(__name__)  #main page @app.route("/")     def translate():     return "welcome nathan's pyglatin translator!"     word1= input("enter word:")     pyg="ay"     word2=word1.lower()[1:len(word1)]     word1=word1.lower()     if len(word1)>1 , word1.isalpha():             if word1[0]=="a" or "e" or "i" or "o" or "u" or "y":                 print(word1+" ---->"+word2+"-"+word1[0]+pyg)             else:                 print(word1+" ---->"+word2+"-"+word1[0]+pyg)     else:             print("please enter word longer 1 character, without numbers.")     print(" ")     print("--note doesn't work words begin vowel--")     print("suggestions? comments? contact me.")  if __name__=="__main__": port=int(os.environ.get('port',5000)) app.run(host='0.0.0.0',port=port) 

i'm able code run (without flask code related hosting on web page) in spyder or jupyter notebook, when try host on pythonanywhere shows "welcome nathan's pyglatin translator!"

what easiest, least-complex way of getting prompt user word , go through script , print new word on screen? it's small thing i'm missing.

pythonanywhere admin here. there 2 possible solutions here.

  • the first way keeps code running in console. able share interactive consoles anonymous strangers, have feature called gist consoles. working, you'd have upload code github gist, , copy gist url pythonanywhere gist consoles service. you'll url allow on internet own console running code

  • the second way involves changing code being web application. use html display form allowing user submit inputs, , display results. on server side, use python process request. colleague giles wrote a basic guide use flask on pythonanywhere. more want (you wouldn't need database part), if follow it, you'll learn how create html pages , process form data...


Comments

Popular posts from this blog

Django REST Framework perform_create: You cannot call `.save()` after accessing `serializer.data` -

Why does Go error when trying to marshal this JSON? -