Reputation: 565
I'm not able to run flask successfully
When i execute the apps_server.py..it stop initialized as follow
Serving Flask app "apps_server" (lazy loading) Environment:production
WARNING: Do not use the development server in a production environment.
Use a production WSGI server instead.
Debug mode: on
It just stuck at that point...and there is no Running on http://localhost:5000/ line show up...
May I know what could be the problem?
This is snippet of the code
from flask import Flask, render_template, Markup, request, jsonify
from flask.helpers import send_file
import os,httplib,json,subprocess
import flask
from flask import request, jsonify, abort, render_template, flash, redirect, url_for
import argparse, sys
import logging
import logging.config
from logging.handlers import RotatingFileHandler
from logging import Formatter
#app = flask.Flask(__name__)
app=Flask(__name__,template_folder='templates')
app.config["DEBUG"] = True
@@Functions and code to execute@@
if __name__ == '__main__':
app.debug = True
app.run(host='0.0.0.0', port=5000)
Please advise further.
Upvotes: 1
Views: 1287
Reputation: 78
I got your code working by doing the following changes:
from flask import Flask, render_template, Markup, request, jsonify
from flask.helpers import send_file
import os,http.client,json,subprocess
import flask
from flask import request, jsonify, abort, render_template, flash, redirect, url_for
import argparse, sys
import logging
import logging.config
from logging.handlers import RotatingFileHandler
from logging import Formatter
app = Flask(__name__)
@app.route("/")
def home():
return "Hello World!"
if __name__ == '__main__':
app.run(host='0.0.0.0', port=5000, debug=True)
Try now ;) Seems like it might have been the debugging. Also, make sure that the @app.route
statement is correct. If you are using a template here and there is just a small mistake, it will not work. I am not sure if your code is correct inside what you call the @@Functions and code to execute@@
. Make sure that whatever you have inside here is correct. Python 3 also renamed httplib to http.client (ref here), so I changed this during the import. However, the code above is working for me.
Also, if you want to use a template (as you've indicated in the post), you can refer to the template as following:
@app.route("/", methods=["GET"])
def home():
return render_template("home.html")
Remember to make a directory called "templates", and put the home.html file there. Flask will automatically look for the "templates" directory.
Upvotes: 1