-2

I've been working on a website for the past year and used python and flask to built it. Recently I encountered a lot of errors and problems and decided to start a new project (pyCharm). I figured I could copy pieces of code into the new project until I encountered a problem and then I'll know what the problem is.

I created three new files as follows:

init.py

from flask import Flask

app = Flask(__name__)
app.config.from_object('config')

config.py

SECRET_KEY = 'you-will-never-guess'

run.py

from app import app
app.run()

If I run this however, the old website shows up (I expected it to be an empty page). How do I start a clean new flask project?

MarkusAfricanus
  • 113
  • 1
  • 16
  • 1
    Did you place the project under some form of subversioning? In that case you could revert to the last version that worked, and check what you changed. – Willem Van Onsem Jul 30 '17 at 16:25
  • 1
    what is serving the website? It could be that your webserver is not reloading the app after you changed it, or you have some cache system running? What does python say when not importing flask? Did the MySQL connection work before? – Pascal Rosin Jul 30 '17 at 16:31
  • If I don't import flask then it returns an error at the lines that contain the app functions, like app.run(). Not sure what is serving the website, how can I check then I'll return with the answer. @ Willem, unfortunately I don't have any form of version control. Most of the time I worked offline so it wasn't practical. – MarkusAfricanus Jul 30 '17 at 17:09
  • If you are not using version control, you really should take some time to learn about that. Well worth the investment. – domoarigato Aug 02 '17 at 12:43
  • Thanks I agree. The thing is I am experiencing the same problems with all flask project, even the one I did as part of a tutorial. – MarkusAfricanus Aug 03 '17 at 11:25

2 Answers2

0

If you are not using version control I suggest the following.

  • Make a new dir with to the original seed
  • Start the seed, using the original instructions (including virualenv)
  • Bring in your changes one by one, with each success save to github, or bitbucket.

This allows the problems to be more clear and safe.

Alexander McNulty
  • 870
  • 1
  • 11
  • 19
0

Build your venv from scratch;

You can clean up your cache as well, include it to your config file:

app.config["CACHE_TYPE"] = "null"
Stephen Rauch
  • 47,830
  • 31
  • 106
  • 135
Sgryt
  • 290
  • 3
  • 13