Skip to content

Commit db19ae1

Browse files
committed
Some final tweaks
1 parent f407e32 commit db19ae1

1 file changed

Lines changed: 9 additions & 10 deletions

File tree

turning-a-script-into-a-website.md

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -181,7 +181,7 @@ A "spinner" will appear next to the button to tell you that PythonAnywhere is wo
181181

182182
Now, we want our Flask app to be able to run our code. We've already extracted it into a
183183
function of its own. It's generally a good idea to keep the web app code -- the basic stuff to
184-
display pages -- from the more complicated processing code (after all, if we were doing the stock analysis
184+
display pages -- separate from the more complicated processing code (after all, if we were doing the stock analysis
185185
example rather than this simple add-two-numbers script, the processing could be thousands of lines long).
186186

187187
So, we'll create a new file for our processing code. Go back to the browser tab that's showing your editor page; up at the top, you'll see
@@ -216,7 +216,7 @@ or other error in the code; just after the line that says
216216

217217
app.config["DEBUG"] = True
218218

219-
Save the file; you'll see that you get a warning icon next to the new line. If you move your
219+
Save the file; you'll see that you get a warning icon next to the new `import` line. If you move your
220220
mouse pointer over the icon, you'll see the details:
221221

222222
<img width="500" src="/static/images/script-to-webapp-import-warning.png">
@@ -543,7 +543,7 @@ and so on, until they're finished, at which point they click a button to get the
543543
Here's a naive implementation. By "naive", I mean that it sort of works in some cases,
544544
but doesn't in general; it's the kind of thing that one might write, only to discover
545545
that when other people start using it, it breaks in really weird and confusing ways.
546-
It's worth going through, though, because the way in which is is wrong is instructive :-)
546+
It's worth going through, though, because the way in which is is wrong is instructive.
547547

548548
Firstly, in our `processing.py` file we have the processing code, just as before:
549549

@@ -630,9 +630,8 @@ Enter some more numbers:
630630

631631
<img src="/static/images/script-to-webapp-globals-free-account-4.png">
632632

633-
But if you have a paid account, you'll see some weird behaviour. The results
634-
will look a bit random, but here's an example of the
635-
kind of thing you might see:
633+
But if you have a paid account, you'll see some weird behaviour. Exactly what you'll
634+
get will depend on various random factors, but it will be something like this:
636635

637636
<img src="/static/images/script-to-webapp-globals-paid-account-1.png">
638637

@@ -958,7 +957,7 @@ A lot of Python scripts don't request the user to enter data a line at a time; t
958957
file as their input, process it, and produce a file as the output. Here's a simple script
959958
that asks for an input filename and an output filename. It expects the input file to contain
960959
a number of lines, each with a comma-separated list of numbers on it. It writes to the
961-
output file the same number of lines, each one with just the sum of the numbers from the
960+
output file the same number of lines, each one containing the sum of the numbers from the
962961
equivalent line in the input file.
963962

964963
def process_data(input_data):
@@ -985,7 +984,7 @@ file that that script requires, and will then provide the output file to downloa
985984
pretty similar to the original app we did -- there's just three phases, input-process-output. So
986985
the Flask app looks very similar.
987986

988-
Firstly, we put our calculationg routine into `processing.py`, as normal:
987+
Firstly, we put our calculating routine into `processing.py`, as normal:
989988

990989
def process_data(input_data):
991990
result = ""
@@ -1027,7 +1026,7 @@ Firstly, we put our calculationg routine into `processing.py`, as normal:
10271026
</html>
10281027
'''
10291028

1030-
Again, we'll go through that line-by-line in a moment (though it's worth noting that
1029+
Again, we'll go through that bit-by-bit in a moment (though it's worth noting that
10311030
although this feels like something that should be much harder than the first case, the
10321031
Flask app is much shorter :-) But let's try it out first -- once you've saved the
10331032
code on PythonAnywhere and reloaded the site, visit the page:
@@ -1054,7 +1053,7 @@ We've got a website where we can upload a file, process it, and download the res
10541053
Obviously the user interface could use a bit of work, but that's left as an exercise for
10551054
the reader...
10561055

1057-
So, how dow the code work? Here's the line-by-line breakdown:
1056+
So, how dow the code work? Here's the breakdown:
10581057

10591058
from flask import Flask, make_response, request
10601059

0 commit comments

Comments
 (0)