My Python server has internal errors since I use static route
up vote
-1
down vote
favorite
I'm trying to run my server who display index.html
using static route. I use static route to link the CSS and JavaScript to my HTML page. For an unkown reason I have a internal server error but the strange thing is that this server was working 5min ago.
from flask import Flask, render_template, request, redirect, url_for, send_from_directory
import socket, json
# create Flask apps
app = Flask(__name__, static_url_path='.')
@app.route('/')
def root():
return app.send_static_file('index.html')
@app.route('/static/<path:path>')
def send_static(path):
return send_from_directory('static', path)
if __name__ == "__main__":
app.run()
My files tree is like this :
x/index.html
x/server.py
x/static/css/y.css
x/static/js/yy.js
python flask server static
add a comment |
up vote
-1
down vote
favorite
I'm trying to run my server who display index.html
using static route. I use static route to link the CSS and JavaScript to my HTML page. For an unkown reason I have a internal server error but the strange thing is that this server was working 5min ago.
from flask import Flask, render_template, request, redirect, url_for, send_from_directory
import socket, json
# create Flask apps
app = Flask(__name__, static_url_path='.')
@app.route('/')
def root():
return app.send_static_file('index.html')
@app.route('/static/<path:path>')
def send_static(path):
return send_from_directory('static', path)
if __name__ == "__main__":
app.run()
My files tree is like this :
x/index.html
x/server.py
x/static/css/y.css
x/static/js/yy.js
python flask server static
What problem are you trying to solve by doing your own static file handling? That code partially duplicates what Flask will do automatically.
– Dave W. Smith
Nov 14 at 18:16
add a comment |
up vote
-1
down vote
favorite
up vote
-1
down vote
favorite
I'm trying to run my server who display index.html
using static route. I use static route to link the CSS and JavaScript to my HTML page. For an unkown reason I have a internal server error but the strange thing is that this server was working 5min ago.
from flask import Flask, render_template, request, redirect, url_for, send_from_directory
import socket, json
# create Flask apps
app = Flask(__name__, static_url_path='.')
@app.route('/')
def root():
return app.send_static_file('index.html')
@app.route('/static/<path:path>')
def send_static(path):
return send_from_directory('static', path)
if __name__ == "__main__":
app.run()
My files tree is like this :
x/index.html
x/server.py
x/static/css/y.css
x/static/js/yy.js
python flask server static
I'm trying to run my server who display index.html
using static route. I use static route to link the CSS and JavaScript to my HTML page. For an unkown reason I have a internal server error but the strange thing is that this server was working 5min ago.
from flask import Flask, render_template, request, redirect, url_for, send_from_directory
import socket, json
# create Flask apps
app = Flask(__name__, static_url_path='.')
@app.route('/')
def root():
return app.send_static_file('index.html')
@app.route('/static/<path:path>')
def send_static(path):
return send_from_directory('static', path)
if __name__ == "__main__":
app.run()
My files tree is like this :
x/index.html
x/server.py
x/static/css/y.css
x/static/js/yy.js
python flask server static
python flask server static
asked Nov 14 at 17:25
Arnaud
11
11
What problem are you trying to solve by doing your own static file handling? That code partially duplicates what Flask will do automatically.
– Dave W. Smith
Nov 14 at 18:16
add a comment |
What problem are you trying to solve by doing your own static file handling? That code partially duplicates what Flask will do automatically.
– Dave W. Smith
Nov 14 at 18:16
What problem are you trying to solve by doing your own static file handling? That code partially duplicates what Flask will do automatically.
– Dave W. Smith
Nov 14 at 18:16
What problem are you trying to solve by doing your own static file handling? That code partially duplicates what Flask will do automatically.
– Dave W. Smith
Nov 14 at 18:16
add a comment |
active
oldest
votes
active
oldest
votes
active
oldest
votes
active
oldest
votes
active
oldest
votes
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Some of your past answers have not been well-received, and you're in danger of being blocked from answering.
Please pay close attention to the following guidance:
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53305693%2fmy-python-server-has-internal-errors-since-i-use-static-route%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
What problem are you trying to solve by doing your own static file handling? That code partially duplicates what Flask will do automatically.
– Dave W. Smith
Nov 14 at 18:16